How would I create a 1x3 png with three rgb pixels?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
patrick99e99
Posts: 7
Joined: 2016-11-08T21:03:34-07:00
Authentication code: 1151

How would I create a 1x3 png with three rgb pixels?

Post by patrick99e99 »

with the convert utility, how can I create a png image that is:

* 1px in height
* 3px in width
* pixel[0] is red
* pixel[1] is green
* pixel[2] is blue

?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: How would I create a 1x3 png with three rgb pixels?

Post by GeeMack »

patrick99e99 wrote:with the convert utility, how can I create a png image that is [...]

Code: Select all

convert xc:#FF0000[1x1] xc:#00FF00[1x1] xc:#0000FF[1x1] +append rgb.png
patrick99e99
Posts: 7
Joined: 2016-11-08T21:03:34-07:00
Authentication code: 1151

Re: How would I create a 1x3 png with three rgb pixels?

Post by patrick99e99 »

Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How would I create a 1x3 png with three rgb pixels?

Post by fmw42 »

This is sufficient:

Code: Select all

convert xc:#FF0000 xc:#00FF00 xc:#0000FF +append rgb.png
IM assumes 1x1 pixel if not specified by -size
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How would I create a 1x3 png with three rgb pixels?

Post by snibgo »

Just to be even more minimalist, colours can be specified by only three hex digits. IM replicated the digits as required.

Code: Select all

convert xc:#F00 xc:#0F0 xc:#00F +append rgb.png
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: How would I create a 1x3 png with three rgb pixels?

Post by glennrp »

This is fine for Windows but on *nix the "#" will comment out the remainder of the line.

Code: Select all

magick xc:#F00 xc:#0F0 xc:#00F +append rgb.png
So, on *nix, use one of these:

Code: Select all

magick xc\#F00 xc:\#0F0 xc:\#00F +append rgb.png
magick xc:"#F00" xc:"#0F0" xc:"#00F" +append rgb.png
magick xc:red xc:lime xc:blue +append rgb.png
Post Reply