Problems converting PNG -> TIF

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
erikwahlstrom
Posts: 1
Joined: 2017-05-05T08:09:52-07:00
Authentication code: 1151

Problems converting PNG -> TIF

Post by erikwahlstrom »

Hi everyone,

I'm having trouble converting a PNG to TIF. Bear with me.

Input:
test.png PNG 1844x1240 1844x1240+0+0 8-bit sRGB 256c 829KB 0.000u 0:00.000

I want to convert this file to a sRGB TIF. I've tried the following.

convert test.png test.tif

This converts the png to a grayscale tif for some reason. Why? The input png contains only grayscale information (a grayscale screenshot created with webkit2png) - could this be the origin of the trouble?

Output:
test.tif TIFF 1844x1240 1844x1240+0+0 8-bit Grayscale Gray 976KB 0.000u 0:00.000

I've tried forcing input and output profiles to sRGB but it still generates an grayscale tif.

convert test.png -profile sRGB\ Profile.icc -profile sRGB\ Profile.icc output_srgb.tif

Please help? A big thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problems converting PNG -> TIF

Post by snibgo »

Try:

Code: Select all

convert test.png -type truecolor test.tif
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: Problems converting PNG -> TIF

Post by fmw42 »

If snibgo's solution does not work, then please post your IM version and platform and your input image. You can upload to any free hosting service such as dropbox.com and put the URL here.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problems converting PNG -> TIF

Post by snibgo »

I should expand. Using IM v6.9.5-3 on Windows 8.1:

Code: Select all

f:\web\im>%IM%convert rose: -colorspace gray test.png

f:\web\im>exiftool test.png
ExifTool Version Number         : 9.02
File Name                       : test.png
Directory                       : .
File Size                       : 2.4 kB
File Modification Date/Time     : 2017:05:05 17:19:53+01:00
File Access Date/Time           : 2016:07:14 17:28:41+01:00
File Permissions                : rw-rw-rw-
File Type                       : PNG
MIME Type                       : image/png
Image Width                     : 70
Image Height                    : 46
Bit Depth                       : 8
Color Type                      : Grayscale
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Gamma                           : 2.2
Background Color                : 255
Modify Date                     : 2017:05:05 17:19:53
Datecreate                      : 2017-05-05T17:19:53+01:00
Datemodify                      : 2017-05-05T17:19:53+01:00
Image Size                      : 70x46
test.png has one channel: "Bit Depth : 8"

Code: Select all

f:\web\im>%IM%convert test.png -type TrueColor test.tiff

f:\web\im>exiftool test.tiff
ExifTool Version Number         : 9.02
File Name                       : test.tiff
Directory                       : .
File Size                       : 4.0 kB
File Modification Date/Time     : 2017:05:05 17:20:24+01:00
File Access Date/Time           : 2013:12:30 22:41:06+00:00
File Permissions                : rw-rw-rw-
File Type                       : TIFF
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian (Intel, II)
Image Width                     : 70
Image Height                    : 46
Bits Per Sample                 : 8 8 8
Compression                     : Adobe Deflate
Photometric Interpretation      : RGB
Fill Order                      : Normal
Strip Offsets                   : 8
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 3
Rows Per Strip                  : 46
Strip Byte Counts               : 3886
Planar Configuration            : Chunky
Page Number                     : 0 1
Predictor                       : Horizontal differencing
Image Size                      : 70x46
test.tif has three channels: "Bits Per Sample : 8 8 8"
snibgo's IM pages: im.snibgo.com
Post Reply