Image resize that adds black borders

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Image resize that adds black borders

Post by Simon Knight » Fri Jan 24, 2014 10:09 am

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?
best wishes
Skids

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Image resize that adds black borders

Post by Simon Knight » Fri Jan 24, 2014 12:32 pm

As an aside use of the crop command causes the live code IDE to crash (6.5.0) see bug report 10910.
best wishes
Skids

Klaus
Posts: 13864
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Image resize that adds black borders

Post by Klaus » Fri Jan 24, 2014 10:43 pm

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

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Image resize that adds black borders

Post by Simon Knight » Sat Jan 25, 2014 3:42 pm

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.
best wishes
Skids

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Image resize that adds black borders

Post by capellan » Mon Jan 27, 2014 12:45 am

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

aron123
Posts: 1
Joined: Sat Oct 11, 2014 5:25 am

Re: Image resize that adds black borders

Post by aron123 » Sat Oct 11, 2014 5:27 am

Thanks for share...

Post Reply

Return to “Multimedia”