convert txt image to png with transparent gets empty image

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

convert txt image to png with transparent gets empty image

Post by ddosimg » 2019-05-07T01:39:18-07:00

Hi, when i convert a txt image to a png image, it gives me an empty file. How can i get the correct image ?

Below is an example:

# step1. create an test image with one red point
convert -size 2x2 xc:none -fill red -draw 'point 1,1' redPoint.png
# step2. convert the image to a txt file
convert redPoint.png redPoint.txt
# step3. convert the txt file back to png file. But it returned a blank picture and the red point disappeared.
convert redPoint.txt save.png
# step4. convert the txt file to png file with "-alpha off".The red point is displayed again, but it is no longer a transparent image.
convert redPoint.txt -alpha off save.png

Question: How can i convert the txt file to a transparent image with red point (step3)?

Platform:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
Imagemagick Version:
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

snibgo
Posts: 12430
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert txt image to png with transparent gets empty image

Post by snibgo » 2019-05-07T04:54:17-07:00

It works fine for me, with IM 6.9.9-50. What is in your redPoint.txt? I get:

Code: Select all

# ImageMagick pixel enumeration: 2,2,65535,srgba
0,0: (0,0,0,0)  #00000000  none
1,0: (0,0,0,0)  #00000000  none
0,1: (0,0,0,0)  #00000000  none
1,1: (65535,0,0,65535)  #FF0000FF  red
snibgo's IM pages: im.snibgo.com

ddosimg
Posts: 10
Joined: 2019-03-19T02:14:53-07:00
Authentication code: 1152

Re: convert txt image to png with transparent gets empty image

Post by ddosimg » 2019-05-07T06:36:52-07:00

snibgo wrote:
2019-05-07T04:54:17-07:00
It works fine for me, with IM 6.9.9-50. What is in your redPoint.txt? I get:

Code: Select all

# ImageMagick pixel enumeration: 2,2,65535,srgba
0,0: (0,0,0,0)  #00000000  none
1,0: (0,0,0,0)  #00000000  none
0,1: (0,0,0,0)  #00000000  none
1,1: (65535,0,0,65535)  #FF0000FF  red
Thanks for your reply, the contents of redPoint.txt are as follows:

Code: Select all

# ImageMagick pixel enumeration: 2,2,255,srgba
0,0: (0,0,0,0)  #00000000  none
1,0: (0,0,0,0)  #00000000  none
0,1: (0,0,0,0)  #00000000  none
1,1: (255,0,0,1)  #FF0000  red
convert redPoint.png -depth 16 redPoint.txt, I get:

Code: Select all

# ImageMagick pixel enumeration: 2,2,65535,srgba
0,0: (0%,0%,0%,0)  #0000000000000000  none
1,0: (0%,0%,0%,0)  #0000000000000000  none
0,1: (0%,0%,0%,0)  #0000000000000000  none
1,1: (100%,0%,0%,1)  #FFFF00000000  red
It works fine with ImageMagick 6.9.10-27 Q16 of macOS. Is this a bug in IM 6.8.9-9 Q16?

snibgo
Posts: 12430
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert txt image to png with transparent gets empty image

Post by snibgo » 2019-05-07T07:01:51-07:00

ddosimg wrote:Is this a bug in IM 6.8.9-9 Q16?
I suppose so. I suggest you use a more recent version.
snibgo's IM pages: im.snibgo.com

ddosimg
Posts: 10
Joined: 2019-03-19T02:14:53-07:00
Authentication code: 1152

Re: convert txt image to png with transparent gets empty image

Post by ddosimg » 2019-05-07T07:14:03-07:00

snibgo wrote:
2019-05-07T07:01:51-07:00
ddosimg wrote:Is this a bug in IM 6.8.9-9 Q16?
I suppose so. I suggest you use a more recent version.
Thanks for your help.
But ...
If I use IM 6.9.10-27 Q16, I will run into another problem. :shock: :shock:
https://www.imagemagick.org/discourse-s ... =1&t=35990

How can I solve these two problems at the same time, thank you.

Post Reply