Having a problem scaling TIFF

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
timthetortoise

Having a problem scaling TIFF

Post by timthetortoise »

All I need to do is scale a (quite large) TIFF. It completes, but when I try to view it, it fails. I can successfully scale and convert to JPEG, but no luck to TIFF from TIFF or to TIFF from JPEG. Any help would be appreciated. Here's my output:

Code: Select all

foobar# convert -monitor -verbose -scale 600 -colors 256 test2drw.tif ../resized/output.tif
TIFF Directory at offset 0x5048a
  Subfile Type: multi-page document (2 = 0x2)
  Image Width: 12000 Image Length: 16800
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 1
  Compression Scheme: CCITT Group 4
  Photometric Interpretation: min-is-white
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 5
  Planar Configuration: single image plane
  Page Number: 0-0
  Software: PlotWorks
Load image: 100%
test2drw.tif TIFF 12000x16800 12000x16800+0+0 DirectClass 1-bit 347.615kb 3.789u 3:10
Classify image colors: 100%
Dither image colors: 100%
  Compute image colors...  : 100%
Save image: 100%
TIFF Directory at offset 0x0
  Image Width: 600 Image Length: 840
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 16
  Compression Scheme: PackBits
  Photometric Interpretation: min-is-black
  FillOrder: msb-to-lsb
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Rows/Strip: 6
  Planar Configuration: single image plane
  Software: ImageMagick 6.3.3 03/05/07 Q16 http://www.imagemagick.org
  DocumentName: ../resized/output.tif
test2drw.tif=>../resized/output.tif TIFF 12000x16800=>600x840 600x840+0+0 PseudoClass 406=>32c 16-bit 38/0.000007/0.042130db 993.979kb 12.773u 0:14
timthetortoise

Re: Having a problem scaling TIFF

Post by timthetortoise »

Temporary solution is to go TIFF to GIF to TIFF.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Having a problem scaling TIFF

Post by anthony »

Look in IM Examples, Common Formats TIFF
http://www.imagemagick.org/Usage/formats/#tiff

hopefully it has the options you need for the TIFF format you need.

TIFF is a BAD format -- too many posibilities, not enough standard implementations.
What works for one program, may not work for another Arrrggghhhh..
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
timthetortoise

Re: Having a problem scaling TIFF

Post by timthetortoise »

Ah, nothing on there really worked for me, so I wrote up a script! I was having problems with some of the converted images having a black bar through them near the end and figured it was because multiple instances were running, so I added a lock file system so they'd only run one at a time. Well, it still happened. Finally figured out that /var/tmp was running out of space so changed that around too. Whaddya know, it works great now and is actually running a bit faster! Here's my script in case anyone's interested.

Code: Select all

#!/usr/compat/linux/bin/bash

srcdir=`echo "$1" | sed 's/[a-zA-Z0-9\.\-\ \#]*\.tif$//'`
dstdir=`echo "$2" | sed 's/[a-zA-Z0-9\.\-\ \#]*\.tif$//'`
tmpdst=`echo "$2" | sed 's/.tif/.gif/'`

lockfile="/usr/home/xxx/xxx/lockfiles/lock"

export MAGICK_TMPDIR="/usr/home/xxx/xxx/imagemagicktmp"

if [ -d "$srcdir" ]; then
        echo "Directory $srcdir exists"
else
        echo "Directory $srcdir does not exist. Exiting"
        exit 1
fi
if [ -e "$1" ]; then
        echo "File $1 exists"
else
        echo "File $1 does not exist. Exiting"
        exit 1
fi

if [ -d "$dstdir" ]; then
        echo "Directory $dstdir exists"
else
        echo "Directory $dstdir does not exist, creating"
        `mkdir -p $dstdir`
fi

while [ -e $lockfile ]
do
        sleep 4
done

echo "Input is $1, output is $2. Medium is $tmpdst"
`touch $lockfile && /usr/local/bin/convert -monitor -verbose +dither -scale 800x600 "$1" "$tmpdst"`
if [ "$3" -ge 0 ]; then
        `/usr/local/bin/mogrify -rotate $3 "$tmpdst"`
fi
`/usr/local/bin/convert +compress "$tmpdst" "$2"`
`rm "$tmpdst"`
`rm $lockfile
This is invoked from a PHP frontend. I know it's not best practice to export the tmpdir every time, but due to the server's instability it's a lot safer at this point. Plus not really any error checking... should probably fix that soon. :? Many thanks to ImageMagick for making what would have taken weeks to code possible to do with a couple days of experimentation!
Post Reply