Page 1 of 1
cropping, resizing and making images transparent
Posted: 2011-03-06T06:35:51-07:00
by DrPL
Hi,
This is my first post, please be kind
I'm experimenting with the imagemagick convert and mogrify commands. I have a lot of png images that I would like to:
set "black" to being transparent
crop the image so that it is 60x108+124+40
and then resize to 25% of the original size.
I've tried the command: mogrify *.png -alpha set -resize 25% -transparent black -crop 60x108+124+40
but other than change the image size from 26.8 kb to 17.1 kb, it doesn't seem to do anything.
Even when I re-order the commands into the sequence I'd like them carried out:
mogrify *.png -alpha set -transparent black -crop 60x108+124+40 -resize 25%
- nothing seems to happen.
Can anyone help?
Many thanks!
Best wishes
Paul
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T09:18:14-07:00
by Bonzo
Try this:
Code: Select all
mogrify -fuzz 1% -transparent black -crop 60x108+124+40 -resize 25% *.png
You might want to use a small amount of Fuzz and do not forget the original will be overwritten!
If it does not work can you post a sample image ?
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T11:14:36-07:00
by DrPL
Hi,
Looks great! When I open up File Browser, or Image Viewer, the image has been cropped as planned. I can't really tell if the black + fuzz has been made transparent. When I open up gimp to have a look, I get a message saying that the "PNG file specifies an offset that causes the layer to be positioned outside the image." Since the original image is 320 x 240 pixels (and yes, I did back up all the originals!), I am a bit mystified at this...
Thanks!
Paul
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T11:19:46-07:00
by Bonzo
Add a +repage
Code: Select all
mogrify -fuzz 1% -transparent black -crop 60x108+124+40 -resize 25% +repage *.png
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T11:28:49-07:00
by Bonzo
My tests opened OK in Gimp but the image was not on the background.
Use +repage to completely remove/reset the virtual canvas meta-data from the images.
All the options are listed here:
http://www.imagemagick.org/script/comma ... ptions.php
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T11:59:10-07:00
by fmw42
perhaps the input png files already have a virtual canvas. so try putting another +repage right after mogrify to remove it from the input image before the rest of the processing and keep the one after the crop at the end to remove the virtual canvas left by the crop. I don't know if this will help, but it is easy to try.
also what version of IM are you using? PNG processing has been under continual change and improvement over the last number of releases. So you might try upgrading to the very latest version of IM
Good reading for new users is at:
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/reference.html
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T16:46:12-07:00
by DrPL
Bonzo wrote:Add a +repage
Code: Select all
mogrify -fuzz 1% -transparent black -crop 60x108+124+40 -resize 25% +repage *.png
It worked beautifully, many thanks!
Re: cropping, resizing and making images transparent
Posted: 2011-03-06T16:50:50-07:00
by anthony
DrPL wrote:I've tried the command: mogrify *.png -alpha set -resize 25% -transparent black -crop 60x108+124+40
but other than change the image size from 26.8 kb to 17.1 kb, it doesn't seem to do anything.
Even when I re-order the commands into the sequence I'd like them carried out:
mogrify *.png -alpha set -transparent black -crop 60x108+124+40 -resize 25%
- nothing seems to happen.
Add a +repage afetr the -crop before the resize.
Also out the images at the end (for mogrify)