Page 1 of 1
[Beginner Question] Convert Tif to PNG
Posted: 2015-09-01T02:06:33-07:00
by Chrism0310
Hello,
I got the task to mass convert product images to a certain size and format and for that I first need to convert all the images into pngs. Most of them are .tifs created in CS4-5. When I try to do so I get a PNG for each and every layer of the tif file.
Sadly the images are from various photographs and most of them are really bad when I look at the layers. Some of them even contain several images which are only visible when you look at the layers, yet most of them look fine when I open them in the usual picture viewers.
So what I'm actually looking for is a script that converts the view of the images as a whole and ignores the layers entirely (guess that's whats meant by "flattening"?). It would be even better if I could seperate the alpha channels as well if the images actually got alpha channels, about half of them don't, because that would be the most favourable thing for the later conversion which follows after this one.
Sadly I'm pretty new to batch programming and even newer to imagemagick. Could you guys help me out please? I don't even know where to start looking for this issue myself :-/
Re: [Beginner Question] Convert Tif to PNG
Posted: 2015-09-01T02:27:03-07:00
by dlemstra
You can prevent this by just getting the first image.
But if you also want to convert multipage tiffs to images you should use the following define:
Code: Select all
convert -define tiff:ignore-layers=true input.tiff output.png
Re: [Beginner Question] Convert Tif to PNG
Posted: 2015-09-01T23:40:04-07:00
by Chrism0310
Hello and big thanks for your fast reply!
up to now I tried the following:
Code: Select all
set bin="D:\Data Storage\Images\bin"
set source="F:\Datastorage\source"
set target="F:\Datastorage\target"
for %%f in (%source%\*) do (
%bin%\mogrify -path %target%\ -format png %%f
echo %%f processed
)
pause
sadly the images aren't as well organized as I wish them to be. the [0] image is not always the alpha channel, I already had that idea as well.
I currently use ImageMagick-6.9.2-0-portable-Q16-x64
and with my code modified to
Code: Select all
set bin="D:\Data Storage\Images\bin"
set source="F:\Datastorage\Test"
set target="F:\Datastorage\target"
for %%f in (%source%\*) do (
%bin%\convert %%f -define tiff:ignore-layers=true "%target%\%%~nf.png"
)
pause
it doesn't work out. I still get all the layers in seperate pngs.
D:\Data Storage\Images>set bin="D:\Data Storage\Images\bin"
D:\Data Storage\Images>set source="F:\Datastorage\Test"
D:\Data Storage\Images>set target="F:\Datastorage\target"
D:\Data Storage\Images>for %f in ("F:\Datastorage\Test"\*) do ("D:\Data Storage\
Images\bin"\convert %f -define tiff:ignore-layers=true ""F:\Datastorage\target"\
%~nf.png" )
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXX.png" )
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "FileSource"; tag ignored. `TIFFFetchNormalTa
g' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "SceneType"; tag ignored. `TIFFFetchNormalTag
' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Wrong data type 3 for "GainControl"; tag ignored. `TIFFReadCustomDi
rectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXX.png" )
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42034 (0xa432) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42036 (0xa434) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXX.pn
g" )
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42240 (0xa500) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXXX.
png" )
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42240 (0xa500) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXX.pn
g" )
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42034 (0xa432) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Unknown field with tag 42036 (0xa434) encountered. `TIFFReadCustomD
irectory' @ warning/tiff.c/TIFFWarnings/878.
convert.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormal
Tag' @ warning/tiff.c/TIFFWarnings/878.
D:\Data Storage\Images>("D:\Data Storage\Images\bin"\convert F:\Datastorage\Test
\XXXXX.tif -define tiff:ignore-layers=true ""F:\Datastorage\target"\XXXXXX.pn
g" )
what am I doing wrong?
[Edit] Problem solved, used IrfanView.