Page 1 of 1

Image resize that adds black borders

Posted: Fri Jan 24, 2014 10:09 am
by Simon Knight
Hi,
I am attempting to create a utility that processes an image and reduces the image to a fixed size. For example my images are taken on a 4/3rds camera and I would like to produce thumb nails that are 80 by 60 pixels in size.

I have code that rescales my images but some of the originals have been cropped e.g to a square format so when the thumb nail is created it is 60 by 60 pixels in size. My question is how do I add black borders to my thumb nail so that the result is an image that measures 80 by 60 pixels i.e. the thumb nail with black pixels 10 by 60 added to each side? I have tried to use the crop function but have not been able to get it to work. I have also looked at Chris Bodel's photoroom stack but the copy I found does not have the resize and crop functions implemented.

Any ideas?

Re: Image resize that adds black borders

Posted: Fri Jan 24, 2014 12:32 pm
by Simon Knight
As an aside use of the crop command causes the live code IDE to crash (6.5.0) see bug report 10910.

Re: Image resize that adds black borders

Posted: Fri Jan 24, 2014 10:43 pm
by Klaus
Hi Simon,

why not put a black filled 80*60 graphic behind the image and export a snapshot from that area
in case the image is not 4:3 (or always) 8)
Know what i mean?


Best

Klaus

Re: Image resize that adds black borders

Posted: Sat Jan 25, 2014 3:42 pm
by Simon Knight
Hi Klaus,

Thanks for you suggestion, am I correct in thinking that a snap shot will be at screen resolution so if I want my downsized image to be larger say 1024 by 700 I will be using a lot of screen area and if I attempt to process a number of files in a folder all the load / display / snapshot / actions will probably mean my application will crawl. At present I am investigating / experimenting with the image data trying to add additional pixels to the edges but I have a way to go.

Re: Image resize that adds black borders

Posted: Mon Jan 27, 2014 12:45 am
by capellan
Simon Knight wrote:As an aside use of the crop command causes the live code IDE to crash (6.5.0) see bug report 10910.
Under Lubuntu Linux, crop works fine with
LiveCode v6.1.2, v6.5.1, v6.5.2 rc1

This works fine:
crop img 1 to the rect of grc 1

This syntax:
crop img 1 to 100,100,105,105

creates a cropped image of just 5 pixels... [ even of 1 pixel... :shock: ]
only if img 1 exists within these stack coordinates.
If img 1 does not exists within these stack coordinates, the IDE
quits suddenly.

A simple test before cropping avoids this crash:

if 100,100 is within the rect of image 1 and 120,120 is within the rect of image 1
then
crop image 1 to 100,100,120,120
else
answer "No image at 100,100,120,120"
end if

Al

Re: Image resize that adds black borders

Posted: Sat Oct 11, 2014 5:27 am
by aron123
Thanks for share...