.TIF to .png Conversion Sometimes Mirroring Images
Posted: 2014-02-19T05:14:22-07:00
I'm running a batch script which recursively runs through a directory tree, and upon finding .TIF files:
Those are the four commands I'm using, rotating where the original's dimensions indicate the file is landscape and applying less compression when the file size is under a threshold.
Does anyone have any ideas on where imagemagick is getting confused?
EDIT:
Further testing has revealed that this is something to do with the file itself - even cutting down the command to the below, some files are still being mirrored and flipped vertically!
EDIT 2:
Oh, "-quiet". That was silly of me, but I used it to hide a bunch of "Unknown field" warnings that didn't seem to affect anything. Looks like I should have tested this on a larger number of individual files in the first place...
Here's my test program: (the structure is just so to match the main program as closely as possible)
And here's the result...
"Depreciated and troublesome old-style JPEG compression mode". I suppose that means there's no way around this? I'll look at detecting that error somehow (or detecting those files) and do something different in their case...... Bah! Bloody scanners!
Final EDIT:
So, any operation on any image that throws that error will causes it to mirror weirdly. I was hoping adding the raw .TIF to the .pdf would work, but nope. I can't think of a way around.
Okay one more EDIT:
EDIT (....and he just kept talking...):
I will try upgrading to 6.8.8-7 :\
If it's fixed I'll be super happy, but I suspect it's more the dodgy compression than IM's handling...
Final final EDIT:
Didn't help. Sadness.
- Converts any .TIF files into .pngs via a couple of different commands based on the original file's size and dimensions
- Packages up all those .pngs into a .pdf and deletes them
- Zips the .pdf using 7zip
Code: Select all
convert -quiet "%1" -rotate 90 -resize "800x" -type Palette -quality 95 -alpha off "%apath%\%~n1.png"
convert -quiet "%1" -rotate 90 "%apath%\%~n1.png"
convert -quiet "%1" -resize "800x" -type Palette -quality 95 -alpha off "%apath%\%~n1.png"
convert -quiet "%1" "%apath%\%~n1.png"
Does anyone have any ideas on where imagemagick is getting confused?
EDIT:
Further testing has revealed that this is something to do with the file itself - even cutting down the command to the below, some files are still being mirrored and flipped vertically!
Code: Select all
convert -quiet "%1" "%~n1.png"
Oh, "-quiet". That was silly of me, but I used it to hide a bunch of "Unknown field" warnings that didn't seem to affect anything. Looks like I should have tested this on a larger number of individual files in the first place...
Here's my test program: (the structure is just so to match the main program as closely as possible)
Code: Select all
@ECHO OFF
FOR %%F IN (*.TIF) DO CALL :SUBCON %%F
GOTO :EOF
:SUBCON
ECHO.
ECHO %1
CALL :NoFlipCon %1
GOTO :EOF
:NoFlipCon
ECHO Compressing to .png...
convert "%1" "%~n1.png"
GOTO :EOF
Code: Select all
C:\Test Area\Operation Area>test.bat
00000043.TIF
Compressing to .png...
convert.exe: Depreciated and troublesome old-style JPEG compression mode, please convert to new-styl
e JPEG compression and notify vendor of writing software. `OJPEGSetupDecode' @ warning/tiff.c/TIFFWa
rnings/847.
00000044.TIF
Compressing to .png...
00000049.TIF
Compressing to .png...
convert.exe: Unknown field with tag 512 (0x200) encountered. `TIFFReadDirectory' @ warning/tiff.c/TI
FFWarnings/847.
convert.exe: Unknown field with tag 515 (0x203) encountered. `TIFFReadDirectory' @ warning/tiff.c/TI
FFWarnings/847.
convert.exe: Unknown field with tag 59932 (0xea1c) encountered. `TIFFReadDirectory' @ warning/tiff.c
/TIFFWarnings/847.
convert.exe: Unknown field with tag 59932 (0xea1c) encountered. `TIFFReadCustomDirectory' @ warning/
tiff.c/TIFFWarnings/847.
convert.exe: Unknown field with tag 512 (0x200) encountered. `TIFFReadDirectory' @ warning/tiff.c/TI
FFWarnings/847.
convert.exe: Unknown field with tag 515 (0x203) encountered. `TIFFReadDirectory' @ warning/tiff.c/TI
FFWarnings/847.
convert.exe: Unknown field with tag 59932 (0xea1c) encountered. `TIFFReadDirectory' @ warning/tiff.c
/TIFFWarnings/847.
C:\Test Area\Operation Area>
Final EDIT:
So, any operation on any image that throws that error will causes it to mirror weirdly. I was hoping adding the raw .TIF to the .pdf would work, but nope. I can't think of a way around.
Okay one more EDIT:
Code: Select all
C:\Test Area\Operation Area>identify -verbose *43.TIF
Image: 00000043.TIF
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 2340x1654+0+0
Resolution: 200x200
Print size: 11.7x8.27
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 246.093 (0.965072)
standard deviation: 35.6628 (0.139854)
kurtosis: 27.2377
skewness: -5.23111
Green:
min: 0 (0)
max: 255 (1)
mean: 246.342 (0.966046)
standard deviation: 35.3986 (0.138818)
kurtosis: 27.4725
skewness: -5.25664
Blue:
min: 0 (0)
max: 255 (1)
mean: 246.42 (0.966352)
standard deviation: 35.0425 (0.137422)
kurtosis: 27.8219
skewness: -5.28923
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 246.285 (0.965824)
standard deviation: 35.3689 (0.138701)
kurtosis: 27.5115
skewness: -5.25904
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: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 2340x1654+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Orientation: LeftBottom
Properties:
date:create: 2014-02-19T13:17:09+00:00
date:modify: 2013-09-16T17:14:17+01:00
signature: ccd33a08ed1cb9ef6bd65208e64812c4522fb466c66c7fad09ff66bd7dab7da1
tiff:endian: lsb
tiff:photometric: YCBCR
tiff:rows-per-strip: 1654
tiff:software: Xerox WorkCentre 7345
Artifacts:
filename: 00000043.TIF
verbose: true
Tainted: False
Filesize: 321KB
Number pixels: 3.87M
Pixels per second: 61.43MB
User time: 0.062u
Elapsed time: 0:01.062
Version: ImageMagick 6.8.8-3 Q16 x64 2014-01-19 http://www.imagemagick.org
identify.exe: Depreciated and troublesome old-style JPEG compression mode, please convert to new-sty
le JPEG compression and notify vendor of writing software. `OJPEGSetupDecode' @ warning/tiff.c/TIFFW
arnings/847.
C:\Test Area\Operation Area>
I will try upgrading to 6.8.8-7 :\
If it's fixed I'll be super happy, but I suspect it's more the dodgy compression than IM's handling...
Final final EDIT:
Didn't help. Sadness.