Page 1 of 1
PNG or JPG to ICO, not squared.
Posted: 2011-03-29T12:19:42-07:00
by Phate
Hello everybody.
I have a little problem, and i'm pretty sure there's a solution.
I'm trying to convert a lot of movie covers to ICO format. The command i use is:
convert -resize 256x256 movie.jpg movie.ico
It converts fine, but the resulting icon is squared and not rectangular like a dvd cover. Is there an option that i need to add?
The result i'm looking for is the same result this site gives:
http://converticon.com/
But i need to be able to do this from the command line because i need it for a script i'm writing.
Thank you
.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T13:08:23-07:00
by fmw42
Post a link to one of your images that needs converting to non-square format.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T13:12:55-07:00
by Bonzo
I thought ico files were always square; it may be something built into the format?
If so try padding the image to make it square before resizing it.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T13:16:23-07:00
by Bonzo
My mistake - just tried it and works OK on a rectangular file.
Your command is slightly wrong and should be:
Code: Select all
convert movie.jpg -resize 256x256 movie.ico
Looking at the thumbnail in windows it looks square but when you click on it to open it is rectangular - strange.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T13:24:05-07:00
by Phate
Bonzo wrote:My mistake - just tried it and works OK on a rectangular file.
Your command is slightly wrong and should be:
Code: Select all
convert movie.jpg -resize 256x256 movie.ico
Looking at the thumbnail in windows it looks square but when you click on it to open it is rectangular - strange.
That's exactly my problem. When you set that icon as a folder icon it looks squared, while using an icon created with the site in the first post it looks fine. I need it rectangular for setting the icon in every folders in my movie's directory, and there are quite a few
.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T13:48:32-07:00
by Bonzo
I would say you need to add extent to pad the image square with either a transparent or white background and then resize it.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T14:05:47-07:00
by Phate
Bonzo wrote:I would say you need to add extent to pad the image square with either a transparent or white background and then resize it.
I tried adding a transparent padding with photoshop and it worked, have you any ideas on how to do this in imagemagick? Great tip by the way, at least now i have something to try
.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T14:12:42-07:00
by Bonzo
If all you images are the same size it is easier but can be calculated with the fx command. How are you running the command windows command, batch, linux, shell etc?
Try this the dimensions of extent need to be correct for the original image ( in this case the original image would be 500px high ):
Code: Select all
convert input.jpg -background transparent -gravity center -extent 500x500 -resize 256x256 movie.ico
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T14:28:43-07:00
by Phate
Bonzo wrote:If all you images are the same size it is easier but can be calculated with the fx command. How are you running the command windows command, batch, linux, shell etc?
Try this the dimensions of extent need to be correct for the original image ( in this case the original image would be 500px high ):
Code: Select all
convert input.jpg -background transparent -gravity center -extent 500x500 -resize 256x256 movie.ico
Thank you very much! It works wonder
.
It will be launched by a script in powershell, a pretty easy one. Resizing an image before running this command is no problem. It will be something like this:
Code: Select all
foreach (element in ls) {
convert .\element\movie.png -resize x500 .\element\movie.png
convert .\element\movie.png -background transparent -gravity center -extent 500x500 -resize 256x256 .\element\movie.ico
rm movie.png
cp C:\Desktop.ini .\element
}
Where in Desktop.ini are all the info on setting the folder's icon. Thank you again, you saved me a lot of time
.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T14:29:53-07:00
by fmw42
convert input.jpg -background transparent -gravity center -extent 500x500 -resize 256x256 movie.ico
Seems to me, to be more efficient, that you want to resize then pad, if you want it to be square.
convert input.jpg -resize 256x256 -background transparent -gravity center -extent 256x256 movie.ico
but then I don't know much about ico files.
Re: PNG or JPG to ICO, not squared.
Posted: 2011-03-29T23:52:01-07:00
by anthony
For methods of padding images and thumbnails see IM examples, Thumbnailling
http://www.imagemagick.org/Usage/thumbnails/#pad