Decode PNG into raw RGB data

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
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151

Decode PNG into raw RGB data

Post by i73 »

Long story short I need to decode to raw RGB in order to encode to Av1 then decode it back to a workable file (testing new tech) and I just need to know if this is the correct way to decode a png to raw RGB:

Code: Select all

convert -size "3x3" -depth 8 encodeTest.png -colorspace RGB encodeTest.rgb
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Decode PNG into raw RGB data

Post by snibgo »

Yes, but -size "3x3" does nothing.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Decode PNG into raw RGB data

Post by fmw42 »

You need to know the size only when reading the raw RGB file. You will also need to know the depth when reading it. See https://imagemagick.org/Usage/formats/#rgb
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151

Re: Decode PNG into raw RGB data

Post by i73 »

fmw42 wrote: 2019-05-02T11:01:40-07:00 You need to know the size only when reading the raw RGB file. You will also need to know the depth when reading it. See https://imagemagick.org/Usage/formats/#rgb
I've added

Code: Select all

-depth 8
to my code, did you miss that or am I doing it wrong?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Decode PNG into raw RGB data

Post by fmw42 »

Code: Select all

convert encodeTest.png -colorspace RGB -depth 8 encodeTest.rgb
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Decode PNG into raw RGB data

Post by snibgo »

Perhaps I should add that "-colorspace RGB" will convert (presumably from non-linear sRGB) to linear RGB. That's fine, if that's what you want, but it may not be.
snibgo's IM pages: im.snibgo.com
Post Reply