Writing and Reading TXT images problems

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
ddosimg
Posts: 10
Joined: 2019-03-19T02:14:53-07:00
Authentication code: 1152

Writing and Reading TXT images problems

Post by ddosimg »

Hi guys and gals.
I was a bit confused when I finished the code below.

command 1:
convert -size 2x1 xc:none \
-fill 'rgb(0,0,0)' -draw 'point 0,0' \
-fill 'rgb(0,0,1)' -draw 'point 1,0' \
-colorspace rgb -depth 8 \
out.png

command 2:
convert out.png -colorspace rgb -depth 8 out.txt

actual output:
```
# ImageMagick pixel enumeration: 2,1,255,rgb
0,0: (0,0,0) #000000 rgb(0,0,0)
1,0: (0,0,0) #000000 rgb(0,0,0)

```

expected:
```
# ImageMagick pixel enumeration: 2,1,255,rgb
0,0: (0,0,0) #000000 rgb(0,0,0)
1,0: (0,0,1) #000000 rgb(0,0,1)

```

Why the outputs is not exact my expected?
Can any one help me ?
Thanks!

Ubuntu 16.04
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
Last edited by ddosimg on 2019-03-19T04:36:56-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Writing and Reading TXT images problems

Post by snibgo »

What version IM, on what platform?

For the past few years, when IM creates an images, it encodes the image as non-linear sRGB. You then convert your image to linear RGB with "-colorspace RGB". This converts the very low value 1/255 to become 0/255.
snibgo's IM pages: im.snibgo.com
ddosimg
Posts: 10
Joined: 2019-03-19T02:14:53-07:00
Authentication code: 1152

Re: Writing and Reading TXT images problems

Post by ddosimg »

Awesome!!!
Thanks for your help.
And sorry for my carelessness, I have added the version information.
ddosimg
Posts: 10
Joined: 2019-03-19T02:14:53-07:00
Authentication code: 1152

Re: Writing and Reading TXT images problems

Post by ddosimg »

snibgo wrote: 2019-03-19T04:10:43-07:00 What version IM, on what platform?

For the past few years, when IM creates an images, it encodes the image as non-linear sRGB. You then convert your image to linear RGB with "-colorspace RGB". This converts the very low value 1/255 to become 0/255.
Awesome!!!
Thanks for your help.
And sorry for my carelessness, I have added the version information.
Post Reply