Convert jpg to ico with ImageMagick

I need help with a button. I want to take the selected image and first resize it to fix its aspect ratio, then convert it to an icon. BUT I would like to preserve the original image, and use a fixed name for the icon.

The following code does not work.

@runmode hide Image HERE REPLACE=always HEIGHT=256 WIDTH=180 QUALITY=100 AS=poster-ico.jpg "C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" poster-ico.jpg poster.ico

If I just resize without the "AS=poster-ico.jpg" and convert using {f} {f|noext}.ico everything works fine, but then my original image is destroyed, and the resulting icon is not named poster.ico

How can I accomplish this task with a single button?

Thanks!

When you say it doesn't work, what happens?

(Any reason not to use convert.exe to do both things at once, since it's being used for the second part as well? That'd make things even easier, and ImageMagick lets you chain multiple steps into a single command for operations like this.)

The image gets converted to poster-ico.jpg, but no icon is created.
No reason not to string up commands, just didn't think of doing it that way.

Ultimately I'm trying to make a single button that takes the selected JPG image, resizes it to control its aspect ratio, turns it into an icon, then sets that icon as the parent folder's icon by coping over a generic desktop.ini and setting the parent folder to read-only to force Windows to look for desktop.ini. It's proving to be far more complicated than I imagined :frowning:

The convert.exe line wasn't working because it needs the full paths. This should work:

Image HERE REPLACE=always HEIGHT=256 WIDTH=180 QUALITY=100 AS=poster-ico.jpg "C:\Program Files (x86)\ImageMagick\convert.exe" {sourcepath}poster-ico.jpg {sourcepath}poster.ico

Using lossy JPG for the intermediate file isn't a great idea, so you could also use BMP instead:

Image CONVERT=bmp HERE REPLACE=always HEIGHT=256 WIDTH=180 QUALITY=100 AS=poster-ico.bmp "C:\Program Files (x86)\ImageMagick\convert.exe" {sourcepath}poster-ico.bmp {sourcepath}poster.ico

Great! Thanks for following up :slight_smile: