[scribus] Adjust frame 2 image api?

Stefano Danzi s.danzi at hawai.it
Mon Mar 25 17:56:20 UTC 2013


It works but sometimes image has wrong offset inside image frame.

I add this:

     sizeObject( xsize, ysize, obj )
     setImageOffset(0, 0, obj)

In my appliction offser has always to be 0.

This fuction don't work if there are a PDF inside the image frame.
I'm studying on a workaround...



Il 25/03/2013 18.45, Craig Bradney ha scritto:
> We should be exposing the internal function to scripter rather than adding more code to scripter. However if that function works it will do the job for now.
>
> Craig
>
>
>
> On 26/03/2013, at 3:45, Stefano Danzi <s.danzi a hawai.it> wrote:
>
>> This morning I've had a flash of inspiration and above a function to do "adjust frame to image" using script.
>> Function need PIL library. It's soo simple... Maybe a Columbus egg? :-)
>>
>> def adjustFrameToImage (obj) :
>>       ## Adjust Frame to Image
>>       ## First select the frame of the image
>>
>>       imagepath=getImageFile(obj)
>>       im = Image.open(imagepath)
>>
>>       xpix_size, ypix_size = im.size
>>       xdpi, ydpi = im.info['dpi']
>>
>>       saveUnit = getUnit()
>>       setUnit(UNIT_INCHES)
>>
>>       xsize = float(xpix_size) / float(xdpi)
>>       ysize = float(ypix_size) / float(ydpi)
>>
>>       sizeObject( xsize, ysize, obj )
>>
>>       #Uncomment to see this info on terminal
>>       #print('xpix_size,ypix_size = (%d, %d); xdpi,ydpi = (%d, %d)'%(xpix_size, xpix_size,xdpi, ydpi))
>>       #print('X %.10f in, Y %.10f in'%(xsize, ysize))
>>
>>       setUnit(saveUnit)
>>
>>
>>
>> Il 10/11/2012 17.20, Mark Heieis ha scritto:
>>> Greg,
>>>
>>> Thanks for the tip. I was thinking about this kind of approach as well, since I already manage the autorotate to correct for image orientation. I would just add the frame adjustment at the same time.
>>>
>>> Cheers
>>>
>>>
>>> On 2012-11-09 17:06, Gregory Pittman wrote:
>>>> On 11/09/2012 12:14 PM, Mark Heieis wrote:
>>>>> Hello
>>>>>
>>>>> Is there a scripting api that mimics the "Adjusts Frame to Image" capability in the UI along the lines of "setScaleImageToFrame()"? So far, I haven't found that functionality in the API documentation. So wondering whether I missed it, it's undocumented or it doesn't exist.
>>>> If you look at the versions of Infobox.py that use PIL (Python imaging library), this is a trivial thing to accomplish.
>>>>
>>>> Using the Image module:
>>>>
>>>>                 im = Image.open(imageload)
>>>>                 xsize, ysize = im.size
>>>>
>>>> and once you have xsize, ysize you use these to size the frame to the image, or use some fraction of each and setScaleImageToFrame().
>>>>
>>>> Greg
>>>>
>>>> ___
>>>> Scribus Mailing List: scribus a lists.scribus.net
>>>> Edit your options or unsubscribe:
>>>> http://lists.scribus.net/mailman/listinfo/scribus
>>>> See also:
>>>> http://wiki.scribus.net
>>>> http://forums.scribus.net
>>>
>>> ___
>>> Scribus Mailing List: scribus a lists.scribus.net
>>> Edit your options or unsubscribe:
>>> http://lists.scribus.net/mailman/listinfo/scribus
>>> See also:
>>> http://wiki.scribus.net
>>> http://forums.scribus.net
>> ___
>> Scribus Mailing List: scribus a lists.scribus.net
>> Edit your options or unsubscribe:
>> http://lists.scribus.net/mailman/listinfo/scribus
>> See also:
>> http://wiki.scribus.net
>> http://forums.scribus.net
> ___
> Scribus Mailing List: scribus a lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>

-- 

Stefano Danzi
Responsabile sistemi informativi

HAWAI ITALIA S.r.l.
Via Forte Garofolo, 16
37057 S. Giovanni Lupatoto Verona Italia

P. IVA 01680700232

tel. +39/045/8266400
fax +39/045/8266401
Web www.hawai.it




More information about the scribus mailing list