[scribus] Adjust frame 2 image api?

Stefano Danzi s.danzi at hawai.it
Mon Mar 25 16:45:41 UTC 2013


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
>



More information about the scribus mailing list