Page 1 of 1

Transparent TIFF lost background

Posted: 2015-01-19T06:53:39-07:00
by Carter J
Hi,

In TIFF-to-JPEG conversion, we are losing transparency and background becomes black.

Command Used:
convert -units pixelsperinch -resample 72 Input.tif[0] output.jpg
and
convert -units pixelsperinch -resample 72 -background none Input.tif[0] output.jpg

How to maintain background transparency?

Identify -verbose Input.tif:
Mime type: image/tiff
Class: DirectClass
Geometry: 1900x2410+0+0
Resolution: 300x300
Print size: 6.33333x8.03333
Units: PixelsPerInch
Type: TrueColorAlpha
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8/16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 80.6859 (0.316415)
standard deviation: 75.0755 (0.294414)
kurtosis: -1.88561
skewness: -0.104343
Green:
min: 0 (0)
max: 255 (1)
mean: 108.424 (0.425192)
standard deviation: 100.28 (0.393253)
kurtosis: -1.95729
skewness: -0.144818
Blue:
min: 0 (0)
max: 255 (1)
mean: 132.391 (0.519181)
standard deviation: 122.298 (0.4796)
kurtosis: -1.96784
skewness: -0.15297
Alpha:
min: 0 (0)
max: 255 (1)
mean: 135.409 (0.531017)
standard deviation: 126.977 (0.49795)
kurtosis: -1.98224
skewness: 0.123055
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 110.273 (0.432443)
standard deviation: 108.135 (0.424057)
kurtosis: -1.7011
skewness: 0.129453
Alpha: none #00000000
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1900x2410+0+0
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Properties:
date:create: 2015-01-19T07:15:19-06:00
date:modify: 2015-01-19T07:15:19-06:00
dc:format: image/tiff
exif:DateTimeDigitized: 2007:09:05 13:35:45
exif:DateTimeOriginal: 2007:09:05 13:35:45
exif:ISOSpeedRatings: 50
exif:PixelXDimension: 1900
exif:PixelYDimension: 2410
icc:name: IEC 61966-2.1 Default RGB colour space - sRGB
photoshop:AuthorsPosition: RACHEL WATSON
photoshop:ColorMode: 3
photoshop:DateCreated: 2007-09-05T13:35:45
photoshop:History: 2012-10-02T14:00:55-04:00 File CT2226_MilitaryGreen.PSD opened
2012-10-02T14:05:36-04:00 File CT2226_BirdsEgg_YJJ.PSD saved
2012-10-02T14:05:49-04:00 File CT2226_BirdsEgg_YJJ.tif saved
2012-10-03T16:15:20-04:00 File CT2226_BirdsEgg_YJJ.tif opened
2012-10-03T16:15:55-04:00 File CT2226_BirdsEgg_YJJ.tif saved
2012-10-03T16:18:13-04:00 File CT2226_FatiqueGreen_VZB.PSD saved
2012-10-03T16:18:20-04:00 File CT2226_FatiqueGreen_VZB.tif saved
2012-10-03T16:19:05-04:00 File CT2226_Sungold_YJP.PSD saved
2012-10-03T16:19:11-04:00 File CT2226_Sungold_YJP.tif saved
2012-12-06T12:23:41-05:00 File CT2112_Sungold_YJP.tif opened
2012-12-06T12:26:51-05:00 File CT2112_Sungold_YJP.PSD saved

photoshop:ICCProfile: sRGB IEC61966-2.1
photoshop:Source: SHOOT-03
photoshop:Urgency: 1
rdf:Alt:


rdf:Bag:




signature: 00962141753bfaf12550e8a214b1c42fd62f3dba0c83a2368369c8ca68902294
stRef:documentID: uuid:A6BDF9B49A5A11DD9EAF9897613A49E6
stRef:instanceID: xmp.iid:C075A9422120681195FEC131F15BF75A
stRef:originalDocumentID: uuid:A6BDF9B49A5A11DD9EAF9897613A49E6
tiff:alpha: unassociated
tiff:artist: RACHEL WATSON
tiff:endian: msb
tiff:make: Phase One
tiff:model: H 25
tiff:photometric: RGB
tiff:rows-per-strip: 22
tiff:software: Adobe Photoshop CS5 Macintosh
tiff:timestamp: 2014:10:02 17:32:49
xmp:CreateDate: 2007-09-05T13:35:45
xmp:CreatorTool: Adobe Photoshop CS5 Macintosh
xmp:MetadataDate: 2014-10-02T17:32:49-04:00
xmp:ModifyDate: 2014-10-02T17:32:49-04:00
xmpMM:DocumentID: uuid:A6BDF9B49A5A11DD9EAF9897613A49E6
xmpMM:InstanceID: xmp.iid:577824F59E2268118083FA960BFC8065
xmpMM:OriginalDocumentID: uuid:A6BDF9B49A5A11DD9EAF9897613A49E6
Clipping path:
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="1900" height="2410">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 1046.5 2344.2
L 1079.43 2342.36
L 1135.63 2337.78
L 1178.2 2332.9
L 1211.13 2327.08
L 1249.16 2323.93
L 1292.31 2318.78
L 1311.04 2314.82
L 1328.07 2312.9
L 1334.31 2313.23
L 1341.13 2313.37
L 1345.1 2312.85
L 1353.62 2310.49
L 1357.02 2308.42
L 1359.98 2304.14
L 1365.92 2289.39
L 1368.37 2279.98
L 1369.46 2272.93
L 1368.65 2239.44
L 1367.86 2205.95
L 1367.18 2184.38
L 1364.46 2157.7
L 1364.9 2116.27
L 1363.78 2035.1
L 1356.67 1888.67
L 1352.39 1826.8
L 1348.27 1763.8
L 1344.28 1717.82
L 1340.96 1695.68
L 1339.18 1648.57
L 1336.99 1420.4
L 1332.95 1329.02
L 1324.75 1182.01
L 1324.92 1166.12
L 1339.38 1070.2
L 1347.83 1046.93
L 1356.45 1058.29
L 1361.28 1066.22
L 1379.02 1100.28
L 1401.06 1146.25
L 1417.99 1183.72
L 1424.89 1201.88
L 1427.98 1208.76
L 1430.25 1211.22
L 1433.66 1212.95
L 1437.06 1213.28
L 1442.74 1211.62
L 1446.9 1210.96
L 1462.61 1215.54
L 1469.04 1215.5
L 1477.94 1214.44
L 1494.97 1208.73
L 1518.24 1197.38
L 1545.93 1180.88
L 1578.41 1158.93
L 1603.39 1138.42
L 1640.29 1109.71
L 1719.76 1057.52
L 1747.58 1042.01
L 1774.67 1028.76
L 1780.34 1027.06
L 1783.65 1025.36
L 1785.56 1022.52
L 1786.12 1019.11
L 1785.37 1015.71
L 1782.55 1011.17
L 1777.1 1004.46
L 1773.21 999.815
L 1771.55 995.274
L 1757.7 959.516
L 1722.2 865.863
L 1687.69 776.751
L 1666.4 719.695
L 1567.63 462.48
L 1518.24 358.473
L 1511.43 349.934
L 1492.69 333.516
L 1477.02 319.839
L 1436.78 287.486
L 1254.84 172.446
L 1242.35 165.646
L 1234.97 161.301
L 1202.05 145.213
L 1143.01 122.327
L 1114.06 113.855
L 1098.32 112.1
L 1091.92 112.011
L 1068.08 116.414
L 1028.74 128.56
L 1013.58 133.171
L 996.549 135.029
L 967.598 134.739
L 920.481 130.074
L 875.635 122.658
L 807.514 106.284
L 768.345 101.315
L 757.559 101.102
L 680.355 116.204
L 666.017 124.019
L 653.675 130.205
L 591.231 156.764
L 532.193 181.517
L 414.685 233.704
L 361.323 263.844
L 345.096 273.864
L 339.184 280.12
L 332.831 288.621
L 316.477 314.637
L 310.552 322.676
L 302.461 338.569
L 296.642 349.353
L 274.922 400.437
L 259.619 431.087
L 248.182 458.899
L 229.227 515.658
L 172.481 673.449
L 136.303 767.102
L 110.574 838.051
L 105.871 848.944
L 97.4002 869.836
L 91.9717 882.323
L 90.8564 887.432
L 91.3441 891.972
L 95.4797 904.459
L 102.066 915.244
L 105.303 918.809
L 125.172 934.701
L 158.097 956.534
L 206.916 984.093
L 238.706 1001.17
L 272.767 1016.47
L 297.176 1023.91
L 303.421 1024.56
L 317.045 1023.47
L 324.425 1022.22
L 360.756 1009.23
L 369.271 1008.09
L 374.948 1006.86
L 378.921 1004.59
L 382.895 1000.5
L 394.555 980.517
L 401.628 971.081
L 405.602 967.289
L 406.538 967.462
L 407.611 969.165
L 411.731 1058.28
L 413.993 1096.87
L 423.683 1338.1
L 424.497 1353.43
L 425.08 1360.8
L 427.464 1535.62
L 430.285 1688.31
L 431.254 1758.12
L 430.187 1797.85
L 424.207 1876.75
L 419.925 1959.61
L 417.421 2004.45
L 416.299 2079.38
L 416.115 2090.73
L 419.501 2119.68
L 417.791 2123.08
L 415.754 2127.05
L 414.645 2132.73
L 414.685 2150.33
L 417.011 2159.98
L 418.8 2164.52
L 420.929 2166.82
L 436.824 2177.28
L 447.042 2181.1
L 516.866 2200.37
L 539.573 2208.57
L 557.738 2218.69
L 567.792 2228.09
L 570.795 2232.21
L 572.225 2236.6
L 575.811 2263.28
L 577.687 2269.52
L 579.636 2272.36
L 606.558 2287.86
L 625.859 2294.57
L 686.032 2304.93
L 716.687 2309.3
L 751.315 2308.58
L 766.074 2307.17
L 804.108 2303.05
L 810.282 2303.01
L 820.571 2305.32
L 847.819 2317.39
L 877.338 2330.96
L 897.206 2338.98
L 907.425 2342.17
L 914.237 2342.66
L 927.293 2342.6
L 942.053 2344.29
L 955.109 2346.18
L 1046.5 2344.2 Z
"/>
</g>
</svg>

Profiles:
Profile-8bim: 13688 bytes
Profile-icc: 3144 bytes
Profile-tiff:37724: 58205104 bytes
Profile-xmp: 41688 bytes
Artifacts:
filename: Input.tif
verbose: true
Tainted: False
Filesize: 61.68MB
Number pixels: 4.579M
Pixels per second: 5.451MB
User time: 0.380u
Elapsed time: 0:01.839

Re: Transparent TIFF lost background

Posted: 2015-01-19T06:57:44-07:00
by glennrp
JPEG does not support transparency, so "none" is black. Use "-background white" (or whatever color you'd like the
transparent parts to become).

Re: Transparent TIFF lost background

Posted: 2015-01-19T07:18:31-07:00
by Carter J
glennrp wrote:JPEG does not support transparency, so "none" is black. Use "-background white" (or whatever color you'd like the
transparent parts to become).
Hi,

We have tried above options, but still issue exists. We also tried without "background" option in the command. In both cases, background became black

Re: Transparent TIFF lost background

Posted: 2015-01-19T09:26:21-07:00
by snibgo
I would explicitly flatten, eg:

Code: Select all

convert Input.tif[0] -units pixelsperinch -resample 72 -background white -flatten output.jpg
Note: I resample after reading the input. I don't know if that is better, as you have a clipping path.

Re: Transparent TIFF lost background

Posted: 2015-01-27T21:36:14-07:00
by Carter J
snibgo wrote:I would explicitly flatten, eg:

Code: Select all

convert Input.tif[0] -units pixelsperinch -resample 72 -background white -flatten output.jpg
Note: I resample after reading the input. I don't know if that is better, as you have a clipping path.

Thanks, Above command working fine for this image. But, we cannot include "-background white -flatten " for all images, as other images may have different background other than white

How to detect that the image has transparent background?

Re: Transparent TIFF lost background

Posted: 2015-01-27T23:20:03-07:00
by snibgo
If the image has no transparency, "-flatten" will do nothing.

Re: Transparent TIFF lost background

Posted: 2015-01-27T23:28:11-07:00
by fmw42
If you want to keep transparency, you need to save to some other format but JPEG, such as PNG or TIFF. Perhaps JP2000 supports transparency? I do not know. But plain JPEG will not keep transparency. So you either have to flatten against some other color besides black or transparent or none, such as white, or use another output format, such as PNG or TIFF

Re: Transparent TIFF lost background

Posted: 2015-02-20T03:52:47-07:00
by Carter J
Carter J wrote:
snibgo wrote:I would explicitly flatten, eg:

Code: Select all

convert Input.tif[0] -units pixelsperinch -resample 72 -background white -flatten output.jpg
Note: I resample after reading the input. I don't know if that is better, as you have a clipping path.

Above command not working for all files..For some files, we still facing same problem..

Any suggestions?

Re: Transparent TIFF lost background

Posted: 2015-02-20T04:38:53-07:00
by snibgo
Put a sample file on dropbox.com or somewhere and paste the link here. Say what command you are using, with what version of IM.

Re: Transparent TIFF lost background

Posted: 2015-03-02T02:02:58-07:00
by Carter J
Hi,
Below is the link for InputFile:
https://www.dropbox.com/s/1gh3xf99ohlco ... e.tif?dl=0

Command tried:
convert -alpha off Input.tif[0] -units pixelsperinch -resample 72 -background white -flatten output.jpg

We are a generic command for all types of files, so using "-alpha off" to resolve issue with below type of files, as discussed in URL viewtopic.php?p=119940#p119940

link for InputFIle:
https://www.dropbox.com/s/7t2qkk9yzaops ... e.tif?dl=0

Please suggest

Re: Transparent TIFF lost background

Posted: 2015-11-03T05:36:35-07:00
by Carter J
We are still facing this issue, any help ?

Re: Transparent TIFF lost background

Posted: 2015-11-03T06:04:09-07:00
by dlemstra
Which version of ImageMagick are you using? I get an image with a white background when I run the command above for both images. Can you clarify your issue?

Re: Transparent TIFF lost background

Posted: 2015-11-03T06:12:52-07:00
by snibgo
I don't understand what issue you are facing.

When an image has transparency but you need an opaque output, you can either (a) turn the transparency off or (b) flatten against some solid colour or (c) something strange like flatten against some other image.