Page 1 of 1

Resizing and Colour change

Posted: 2017-05-09T07:21:52-07:00
by TheLads
I am having trouble with resizing and changing the colour of my image.

I have a jpeg and want to change it to the following requirements:
• The image must be a 100x100 PNG
• The background must be transparent (not white or light gray)
• The only color should be #333333
• There should be no white or any other colors in the picture, only transparent and the main color with various levels of alpha
• There should be as little padding as possible


At the moment this is as far as I have gotten:

Code: Select all

"convert.exe" rose.jpeg -gravity center -extent 100x100! -transparent white -fuzz 99.9%% -set filename:f %%t %%[filename:f].png 
-fill and -opaque are not giving me my desired result.
I am using Windows 7 and ImageMagick-7.0.5-Q16

Re: Resizing and Colour change

Posted: 2017-05-09T07:26:09-07:00
by snibgo
TheLads wrote:There should be no white or any other colors in the picture, only transparent and the main color with various levels of alpha
What should determine the level of alpha?

Re: Resizing and Colour change

Posted: 2017-05-09T07:30:27-07:00
by TheLads
To be honest, I am unsure what this means. I have been given these requirements without much explanation

Re: Resizing and Colour change

Posted: 2017-05-09T07:40:30-07:00
by snibgo
Creating an image that satisfies the requirements is easy. For example, half the pixels might be #333333 opaque, and the other half fully transparent.

But I suppose the output must be, in some way, dependent on the input.

Re: Resizing and Colour change

Posted: 2017-05-09T07:54:42-07:00
by TheLads
https://www.iconfinder.com/icons/298812 ... n#size=128
This is the type of image that would be the input

Re: Resizing and Colour change

Posted: 2017-05-09T08:52:39-07:00
by snibgo
I assume your input is one of the PNG files, and your output should have the same transparency (alpha), but all pixels should have the colour #333333. Windows BAT syntax:

Code: Select all

convert ^
  1494360567_link-external.png ^
  -trim +repage ^
  ( -clone 0 -fill #333333 -colorize 100 ) ^
  ( -clone 0 -alpha extract ) ^
  -delete 0 ^
  -alpha off -compose CopyOpacity -composite ^
  -resize "100x100^!" ^
  out.png