#!/bin/bash ################################################# # Script to convert RGB image files to CMYK tiff with a selected color profile and compression method # script does not modify the file which you select, it creates a new with '_CMYK.tif' extension. # It cannot convert a directory but you can select several files. # # # ################################################# version="0.1" # ###### Default = English ##### title="RGBimg2CMYKtiff "$version"" pleasesel="Please select at least one file." noselec=""$title" Script to convert RGB image files to CMYK tiff with a selected color profile. "$pleasesel"" nobin="Program Imagemagick/convert is not installed, please install !" warning="Warning" comp="Tif compression" exportof="tiff compression selection" Resolution="Resolution" resolinf="Select image resolution" inputcol="Input color profile" outputcol="Output color profile" Working="Working" Done="Done!" case $LANG in ######## Magyarul ######### hu* ) title="images2jpg "$version"" pleasesel="Kérlek válassz ki legalább 1 fájlt!" noselec=""$title"konverter RGB képből CMYK tiffbe."$pleasesel"" warning="Figyelem" nobin="Az Imagemagick nem található, telepítsd!" comp="Tif tömörítés" exportof="TIFF tömörítési mód kiválasztása" Resolution="Felbontás (dpi)" resolinf="Kép felbontás kiválasztása" inputcol="Bemeneti színprofil" outputcol="Kimeneti színprofil" Working="Konverzió folyamatban" Done="Az exportálás kész!" ;; esac ################################################# # PROGRAM Section ######## Test dependency ######################## which convert 2>/dev/null if [ $? != 0 ] then zenity --error --title="$title" --text="$nobin" exit 0 fi ######## File selection check ######## if [ $# -eq 0 ]; then zenity --error --title="$warning" --text="$noselec" exit 1 fi ######## creating output directory ######## mkdir CMYK_tiff_output ######## quality settings ######## while [ ! "$compress" ] do compress=`zenity --title "$title" --list --radiolist --height=300 --width=300 --column="" --column="$comp" TRUE "LZW" FALSE "JPEG" FALSE "JPEG2000" FALSE "Lossless" FALSE "LosslessJPEG" FALSE "None" --text "$exportof"` if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 done ######## resolution settings ######## while [ ! "$sample" ] do sample=`zenity --title="$title" --list --radiolist --height=300 --width=300 --column="" --column="$Resolution:" FALSE "90x90" FALSE "120x120" TRUE "300x300" FALSE "600x600" FALSE "1200x1200" --text "$resolinf"` if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 done ######## color profile directory ######## iccdir="/usr/share/color/icc" ######## input profile settings ######## while [ ! "$inputprofile" ] do inputprofile=`zenity --title="$title" --list --radiolist --height=300 --width=300 --print-column=3 \ --column="selection" --column="$inputcol" --column=file\ FALSE AdobeRGB1998 "$iccdir/AdobeRGB1998.icc"\ FALSE ColorMatchRGB "$iccdir/ColorMatchRGB.icc"\ TRUE sRGB "$iccdir/sRGB_adobe.icm"\ FALSE eciRGB_v2 "$iccdir/eciRGB_v2.icc"\ FALSE eciRGB_v2_ICCv4 "$iccdir/eciRGB_v2_ICCv4.icc"\ FALSE sRGB_v4_ICC_preference "$iccdir/sRGB_v4_ICC_preference.icc"\ FALSE sRGB_IEC61966-2-1_black_scaled "$iccdir/sRGB_IEC61966-2-1_black_scaled.icc"\ FALSE sRGB_IEC61966-2-1_no_black_scaling "$iccdir/sRGB_IEC61966-2-1_no_black_scaling.icc"` if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 done ######## output profile settings ######## while [ ! "$outputprofile" ] do outputprofile=`zenity --title="$title" --list --radiolist --height=300 --width=300 --print-column=3 \ --column="" --column="$outputcol" --column=file\ FALSE CoatedFOGRA27 "$iccdir/CoatedFOGRA27.icc" \ FALSE UncoatedFOGRA29 "$iccdir/UncoatedFOGRA29.icc" \ FALSE EuroscaleUncoated "$iccdir/EuroscaleUncoated.icc" \ TRUE EuroscaleCoated "$iccdir/EuroscaleCoated.icc" \ FALSE ISOcoated_v2_eci "$iccdir/ISOcoated_v2_eci.icc" \ FALSE ISOuncoated "$iccdir/ISOuncoated.icc" \ FALSE ISOwebcoated "$iccdir/ISOwebcoated.icc" \ FALSE USWebCoatedSWOP "$iccdir/USWebCoatedSWOP.icc"` if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 done ######## rendering intent settings ######## while [ ! "$intent" ] do intent=`zenity --title="$title" --list --radiolist --height=300 --width=300 --column="" --column="Rendering intent" TRUE "Perceptual" FALSE "Absolute" FALSE "Relative" FALSE "Saturation"` if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 done ######## Conversion ######## while [ $# -gt 0 ]; do picture=$1 tif_file=`echo "$picture" | sed 's/\.\w*$/_CMYK.tif/'` /usr/bin/mogrify -profile "$inputprofile" -profile "$outputprofile" -intent "$intent" -colorspace CMYK -depth 8 -set density "$sample" -compress "$compress" -path CMYK_tiff_output -format tiff "$picture" | zenity --progress --text="$Working" --pulsate --auto-close shift done