[Scribus] Export to CMYK JPEG or TIFF?

Craig Ringer craig
Sat Mar 1 18:43:05 CET 2008

Vossler T wrote:
> Hi
> you mention that you used tifficc to batch process image file to cmyk
> images,  I only make this works   "jpegicc -oprinter.icm inrgb.jpg
> outcmyk.jpg" in windows environment, 
> is that a options could let us  jpegicc -oprinter.icm "soure path floder
> image file"  "destination path"  something like  jpegicc -oprinter.icm
> e:/photos/*.jpg  e:/cmyk/  

The process I use tifficc in first converts from a printer-specific CMYK 
tiff to an sRGB tiff, then feeds the result into ImageMagick's mogrify 
tool to resize the images.  It's really very simple, in that most of it 
is documentation and error handling.

If you're working on Windows a shell script won't be much good to you. 
You could use the cmd.exe shell, but it's really pretty pathetic and the 
syntax is truly awful even compared to berkeley-derived shells like 
bash. Windows Scripting Host would work if you're one of the three 
people in the world who knows how to use it. Personally I'd recommend 
using your preferred scripting language to write a short script to do 
the job. In your position on Windows I'd be using Python.

Alternately, you could install Cygwin (a UNIX-like environment for 
Windows) and use the attached script, maybe with a few tweaks for 
cygwin. I don't recommend that, though, and I think you're much better 
off writing a little script to do it yourself.

An untested example in quick and dirty Python with little error handling 
and no directory recursion follows. You could improve it pretty easily 
even if you know little or no Python.

#!/usr/bin/env python
import os
import sys
if len(sys.argv) < 3:
   print "Usage: %s input_dir output_dir"
for infile in [ x for x in os.listdir(argv[1]) if os.path.isfile(x) ]:
   fileext = os.path.basename(infile).split(".")[-1]
   if fileext.lower() not in ["tiff", "tif"]:
   outfile = os.path.join(argv[2],os.path.basename(infile)
   ret = os.execv(tifficc_path, tifficc_args + [infile, outfile])
   if ret != 0:
       print "WARNING: Failed to convert %s" % infile

Obviously lots can be improved in the above: capturing the tifficc error 
and reporting it neatly rather than letting it be dumped on stderr; 
checking for indir = outdir (note: this can never be done perfectly due 
to ntfs junctions etc, but in practice is useful anyway); making it less 
ugly, etc.

I've attached the shell script I use. As you can see it's nothing special.

Craig Ringer



set -u

if test $# -ne 1 ; then
        echo ""
        echo "Usage: $0 /absolute/path/to/pages/directory"
        echo ""
        echo "  The target directory will be recursively scanned for images to convert."
        echo "  This script will actually work with any directory containing TIFF images as the target."
        echo "  To get an accurate conversion the images should be sRGB or have an embedded profile."
        echo ""
        echo "  Result images will be written to a newly created subdirectory of the  current directory:"
        echo "    (`pwd`/webimg-`date -I`)"
        echo ""
        exit 1

if test "${srcdir:0:1}" != "/" ; then
        echo "Input path wasn't absolute. Using:"
        echo "  $srcdir"
        echo ""

mkdir -p webimg-`date -I`
outdir="`pwd`/webimg-`date -I`"
echo "Will write output to: $outdir"
cd "$outdir"

# Num leading chars of path to strip
declare -i chstrip=$(( ${#1} ))

for f in `find "$srcdir" -type d -name .AppleDouble -prune -fprint /dev/null -o  -type f -iname \*.tif -print -o -type f -iname \*.tiff` ; do
        # Strip path prefix
        # and replace / with _ throughout the string
        echo "Processing <<$f>> to <<$outfile>> ..."
        tifficc -t0 "$f" "$outfile"
        if test "$tifficcerr" -ne 0 ; then
                echo "TiffICC: $tifficcerr. I'll copy it over and see what happens. This is usually OK."
                echo -n "File info on original: "
                file "$f"
                cp "$f" "$outfile"
        mogrify -resize 320x320 -format jpeg "${outfile}"
        if test "$mogrifyerr" -ne 0 ; then
                echo "Mogrify error $mogrifyerr; You'll have to fix ${outfile} yourself."
                rm "${outfile}"

echo "Finished, wrote output to $outdir"

More information about the scribus mailing list