Hi.
I have another commandline-problem where I can't get rid of:
How to pick a color from an image's corner and use it as the background-color.
There seems to exist an api for that ("getImagePixelColor(1, 1)") but I would need it in commandline.
Regards,
Atze
How to pick a color from an image's corner and use it...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to pick a color from an image's corner and use it...
This makes a 100x100 background color image from the color at coordinates at 20,20 of someimage.jpg
coords="20,20"
color=`convert someimage.jpg -format "%[pixel:s.p{$coords}]" info:`
convert -size 100x100 xc:"$color" background.jpg
see fx escapes
http://www.imagemagick.org/Usage/transform/#fx_escapes
coords="20,20"
color=`convert someimage.jpg -format "%[pixel:s.p{$coords}]" info:`
convert -size 100x100 xc:"$color" background.jpg
see fx escapes
http://www.imagemagick.org/Usage/transform/#fx_escapes
Re: How to pick a color from an image's corner and use it...
@fmw42:
Ok, thanks for info. I will take a deeper look.
@Bonzo:
Thanks for the link. I wonder that I didn't find it yet.
This looks really interesting:
Looks quite complecated. I'm Windows only user, sorry that I didn't mention it yet.
Could someone help me 'translate' it to DOS-batch syntax?
Regards,
Atze
Ok, thanks for info. I will take a deeper look.
@Bonzo:
Thanks for the link. I wonder that I didn't find it yet.
This looks really interesting:
I'm not sure, if I really understand this syntax. It seems to be a Unix-shell syntax, right?convert logo: -transparent $(echo `convert logo: -format "%[pixel:p{0,0}]" info:`) logo_tmp.png
Looks quite complecated. I'm Windows only user, sorry that I didn't mention it yet.
Could someone help me 'translate' it to DOS-batch syntax?
Regards,
Atze
Re: How to pick a color from an image's corner and use it...
Finaly I got it convrted to DOS-syntax:
Atze
Thanks for help!FOR /F "delims=" %%A IN ('convert.exe input.jpg -format "%%[pixel:s.p{0,0}]" info:') DO SET BACKCOLOR=%%A
Atze
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to pick a color from an image's corner and use it...
Here is an alternative from the 'Canvas Creation' page of IM examples...fmw42 wrote:This makes a 100x100 background color image from the color at coordinates at 20,20 of someimage.jpg
http://www.imagemagick.org/Usage/canvas/#solid
Code: Select all
convert someimage.jpg -crop 1x1+20+20 +repage -scale 100x100\! background.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to pick a color from an image's corner and use it...
anthony wrote:Here is an alternative from the 'Canvas Creation' page of IM examples...fmw42 wrote:This makes a 100x100 background color image from the color at coordinates at 20,20 of someimage.jpg
http://www.imagemagick.org/Usage/canvas/#solid
WARNING: JPG is lossy, colors may not be exact!Code: Select all
convert someimage.jpg -crop 1x1+20+20 +repage -scale 100x100\! background.png
Yes, Anthony's method is more elegant and simpler.