Image resize that adds black borders
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Image resize that adds black borders
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?
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
Skids
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Image resize that adds black borders
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
Skids
Re: Image resize that adds black borders
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)
Know what i mean?
Best
Klaus
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)
Know what i mean?
Best
Klaus
-
- Posts: 854
- Joined: Wed Nov 04, 2009 11:41 am
- Location: Gunthorpe, North Lincs, UK
Re: Image resize that adds black borders
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.
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
Skids
Re: Image resize that adds black borders
Under Lubuntu Linux, crop works fine withSimon Knight wrote:As an aside use of the crop command causes the live code IDE to crash (6.5.0) see bug report 10910.
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... ]
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
Thanks for share...