TIF to JPG, DPI and Clipping Path

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
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

TIF to JPG, DPI and Clipping Path

Post by eafalcao »

Hi all...

I'm new in dealing with Image Magick so, this may be a silly question.

I need to convert one tif image in two jpg's. The dpi must be changed, however the width and heigth must remain as well as the clipping path.

I'm doing this:
convert tif1.tif -resample 150x150 -resize 952x3424 tif_result_1.jpg
and
convert tif1.tif -resample 75x75 -resize 952x3424 tif_result_2.jpg

952x3424 is the original width and heigth that must remain.

But when I see the Windows properties of the result images, the dpis remains 300 (like the original). The same thing happens when i open the image in Photoshop.
If I use -strip option, as i've read in some posts, the dpis is shown correctly... however the image lose the clipping path.

This only happens when i try to convert tif to jpg. If i convert jpg in tif everything goes well.

So, what I must do to this works? Any one can help me?

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

try using -density instead of what you are doing

convert tif1.tif -density 150 tif_result_1.jpg
convert tif1.tif -density 75 tif_result_2.jpg

see
http://www.imagemagick.org/script/comma ... hp#density
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

I also tried to use density and size... but the result is the same.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

-size will do nothing. Just -density should change the dpi and leave the image size unchanged. You might try adding -strip.

convert tif1.tif -strip -density 150 tif_result_1.jpg

Can you post a link to your input image so others can test it?
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

Hi...

-strip will work, however the result image lose the Clipping Path... and I really need it.

Later I'll post the image - I have to ask for permission.
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

The following works for me on IM 6.7.6.1 Q16 Mac OSX Snow Leopard

convert tif1.tif -density 150 tif1_150.jpg

Note in the following the resolution is 150x150

identify -verbose tif1_150.jpg

Code: Select all

 Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 952x3424+0+0
  Resolution: 150x150
  Print size: 6.34667x22.8267
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  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: 220.745 (0.865666)
      standard deviation: 49.8182 (0.195366)
      kurtosis: 3.09939
      skewness: -1.9664
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 218.927 (0.858539)
      standard deviation: 54.9942 (0.215663)
      kurtosis: 4.03836
      skewness: -2.10081
    Blue:
      min: 22 (0.0862745)
      max: 255 (1)
      mean: 228.688 (0.896817)
      standard deviation: 45.5051 (0.178451)
      kurtosis: 6.3883
      skewness: -2.53638
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 222.787 (0.873674)
      standard deviation: 50.2558 (0.197081)
      kurtosis: 4.56186
      skewness: -2.219
  Rendering intent: Perceptual
  Gamma: 0.45455
  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)
  Interlace: None
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 952x3424+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 92
  Orientation: Undefined
  Properties:
    crs:AlreadyApplied: True
    date:create: 2012-03-21T10:52:21-07:00
    date:modify: 2012-03-21T10:52:21-07:00
    dc:format: image/tiff
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    photoshop:ColorMode: 3
    photoshop:DateCreated: 2011-03-02
    photoshop:ICCProfile: Adobe RGB (1998)
    photoshop:LegacyIPTCDigest: F0F353A5F3F5BAA0C582614BE33D4B58
    rdf:Alt: 
    rdf:Bag: 
               
            
    signature: 5cb70b3a45904a1d457e6adfecf88fe4530e94e3e39df3353377a5c5b1c3e38a
    stRef:documentID: uuid:29D3172B3AE8E011A44DED58EA0AF20D
    stRef:instanceID: xmp.iid:A2BE9B21EA2AE111974DED05C10F5C6B
    stRef:originalDocumentID: xmp.did:F77F11740720681195FEFAC04CA66572
    xmp:CreateDate: 2011-09-26T14:22:18+02:00
    xmp:CreatorTool: Adobe Photoshop CS5 Windows
    xmp:MetadataDate: 2011-12-20T10:38:02+01:00
    xmp:ModifyDate: 2011-12-20T10:38:02+01:00
    xmpMM:DocumentID: uuid:29D3172B3AE8E011A44DED58EA0AF20D
    xmpMM:InstanceID: xmp.iid:A4BE9B21EA2AE111974DED05C10F5C6B
    xmpMM:OriginalDocumentID: xmp.did:F77F11740720681195FEFAC04CA66572
    xmpRights:Marked: True
    xmpRights:WebStatement: http://www.opv.se
  Clipping path: 
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="952" height="3424">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 307.617,240.034
C 307.617,240.034 283.938,233.524 279.794,229.38
C 275.65,225.237 275.65,215.174 277.426,212.807
C 279.202,210.439 286.306,203.928 286.306,203.928
L 285.714,61.8708
L 288.674,53.5841
C 288.674,53.5841 296.961,26.3563 318.865,18.0698
C 340.768,9.78288 389.902,-1.46289 466.268,0.904306
C 542.633,3.27212 576.968,5.63972 589.991,13.3346
C 603.015,21.0293 611.895,31.6836 613.671,34.643
C 615.447,37.6025 617.814,48.257 617.814,48.257
L 621.366,54.1759
L 626.694,157.168
L 624.326,161.311
L 626.694,195.642
L 625.51,200.969
L 622.55,203.336
C 622.55,203.336 631.43,210.439 630.838,214.582
C 630.246,218.726 634.39,218.726 629.062,221.093
C 623.734,223.461 599.463,234.707 599.463,234.707
L 600.055,267.262
L 600.055,282.652
L 600.647,289.163
C 600.647,289.163 745.09,550.785 770.545,601.689
C 796,652.593 845.727,766.831 861.71,818.919
C 877.694,871.006 884.206,886.988 884.206,886.988
C 884.206,886.988 901.373,905.337 911.437,931.381
C 921.5,957.425 924.46,998.266 923.868,1004.78
C 923.276,1011.29 922.092,1014.25 922.092,1014.25
L 925.644,1102.44
L 922.092,1115.46
C 922.092,1115.46 925.644,1147.43 925.052,1153.35
C 924.46,1159.26 929.788,1485.4 929.788,1485.4
L 930.972,1722.76
L 929.788,1738.15
L 929.196,1785.5
L 931.564,1797.93
L 930.972,1809.18
C 930.972,1809.18 928.012,1913.94 926.828,1922.23
C 925.644,1930.52 925.644,1935.85 914.396,1950.05
C 903.149,1964.26 903.149,1966.62 907.293,1972.54
C 911.437,1978.46 928.012,1986.16 927.42,2009.24
C 926.828,2032.33 926.236,2048.31 921.5,2053.63
C 916.764,2058.96 912.028,2057.78 911.437,2064.29
C 910.845,2070.8 909.069,2074.94 916.764,2083.23
C 924.46,2091.52 925.052,2100.4 925.052,2112.23
C 925.052,2124.07 923.868,2145.38 922.092,2149.52
C 920.316,2153.67 907.293,2158.99 904.925,2163.73
C 902.557,2168.46 895.453,2181.49 905.517,2188
C 915.58,2194.51 923.868,2204.57 924.46,2218.18
C 925.052,2231.8 941.035,2568 940.444,2595.23
C 939.852,2622.46 928.604,2684.01 928.604,2684.01
C 928.604,2684.01 944.587,2734.33 945.771,2788.19
C 946.955,2842.05 949.323,2956.88 946.955,2960.43
C 944.587,2963.99 933.34,2971.09 933.34,2979.38
C 933.34,2987.66 942.219,2992.4 945.179,2998.32
C 948.139,3004.24 949.323,3011.93 949.323,3025.54
C 949.323,3039.16 951.099,3066.39 947.547,3068.75
C 943.995,3071.12 936.3,3081.18 938.076,3088.88
C 939.852,3096.57 950.507,3104.86 950.507,3118.47
C 950.507,3132.09 957.019,3183.58 933.34,3250.47
C 909.661,3317.35 875.326,3370.63 859.342,3376.54
C 843.359,3382.46 759.89,3409.1 716.675,3411.47
C 673.461,3413.83 653.925,3407.92 648.597,3403.18
C 643.27,3398.44 638.534,3393.71 638.534,3393.71
C 638.534,3393.71 623.734,3417.39 616.63,3418.57
C 609.527,3419.75 405.886,3426.26 396.414,3422.71
C 386.942,3419.16 377.471,3404.96 370.367,3402
C 363.263,3399.04 362.079,3398.44 357.935,3403.18
C 353.791,3407.92 340.176,3418.57 334.848,3418.57
C 329.52,3418.57 208.756,3412.65 182.709,3402.59
C 156.662,3392.53 147.19,3386.61 137.127,3386.61
C 127.063,3386.61 112.264,3387.79 86.8084,3354.64
C 61.3533,3321.5 48.3297,3297.23 36.4902,3258.16
C 24.6506,3219.1 13.995,3138.6 13.995,3138.6
C 13.995,3138.6 14.5869,3118.47 16.3628,3111.96
C 18.1388,3105.45 28.2025,3097.16 28.2025,3097.16
C 28.2025,3097.16 19.3227,3084.14 16.9548,3064.61
C 14.5869,3045.08 11.627,3011.93 17.5468,3003.05
C 23.4666,2994.17 25.8345,2989.44 25.8345,2989.44
C 25.8345,2989.44 15.1789,2968.72 13.995,2957.48
C 12.811,2946.23 15.7708,2820.15 15.7708,2820.15
C 15.7708,2820.15 23.4666,2760.37 25.2426,2749.12
C 27.0185,2737.88 28.7944,2732.55 28.7944,2732.55
C 28.7944,2732.55 27.0185,2723.08 23.4666,2692.3
C 19.9147,2661.52 16.9548,2625.42 16.3628,2593.45
C 15.7708,2561.49 26.4265,2267.31 26.4265,2267.31
C 26.4265,2267.31 24.6506,2231.8 25.8345,2222.33
C 27.0185,2212.86 33.5303,2208.12 39.4501,2197.47
C 45.3699,2186.81 50.6977,2191.55 48.9217,2182.67
C 47.1458,2173.79 29.9784,2165.5 25.8345,2154.85
C 21.6907,2144.2 22.2826,2110.46 22.2826,2110.46
C 22.2826,2110.46 24.6506,2094.48 28.7944,2090.33
C 32.9383,2086.19 36.4902,2087.97 32.9383,2077.9
C 29.3864,2067.84 19.3227,2054.82 19.3227,2049.49
C 19.3227,2044.16 15.7708,2008.06 19.9147,1999.18
C 24.0586,1990.3 35.8982,1988.52 37.0821,1982.01
C 38.2661,1975.5 38.2661,1967.81 38.2661,1967.81
C 38.2661,1967.81 21.6907,1959.52 17.5468,1947.09
C 13.403,1934.66 11.627,1829.3 11.627,1829.3
L 9.25903,1800.89
L 11.035,1786.68
L 11.035,1728.09
L 8.07513,1719.8
L 5.70722,1462.91
L 7.48318,1310.79
L 2.74736,1233.25
C 2.74736,1233.25 5.70722,1216.68 6.29917,1209.58
C 6.89117,1202.47 6.29917,1177.02 6.29917,1177.02
L 9.25903,1173.47
L 2.15535,1159.86
L 3.33925,1137.96
C 3.33925,1137.96 7.48318,1111.91 3.93125,1106.58
C 0.379388,1101.26 -0.212562,1098.89 0.379388,1086.46
C 0.971394,1074.03 2.74736,964.527 2.74736,964.527
C 2.74736,964.527 -4.94838,958.608 18.1388,915.991
C 41.2261,873.374 53.6576,854.433 57.2095,842.595
C 60.7613,830.757 99.2401,700.537 135.351,627.141
C 171.462,553.745 269.73,365.519 269.73,365.519
C 269.73,365.519 309.985,291.53 309.985,287.979
C 309.985,284.428 307.617,240.034 307.617,240.034 Z
"/>
</g>
</svg>

  Profiles:
    Profile-8bim: 9300 bytes
    Profile-icc: 560 bytes
      Description: Adobe RGB (1998)
      Manufacturer: Adobe RGB (1998)
      Model: Adobe RGB (1998)
      Copyright: Copyright 1999 Adobe Systems Incorporated
    Profile-xmp: 33236 bytes
  Artifacts:
    filename: 1tif1_150.jpg
    verbose: true
  Tainted: False
  Filesize: 325KB
  Number pixels: 3.26M
  Pixels per second: 27.16MB
  User time: 0.120u
  Elapsed time: 0:01.119
  Version: ImageMagick 6.7.6-1 2012-03-17 Q16 http://www.imagemagick.org
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

But in Photoshop, the image appears with 300 dpi. Do you know why?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

Sorry, no, I do not know why? Photoshop may keep special information in its meta data different from the norm. That is probably why when you use -strip it works out correctly. But I am not an expert on that. Perhaps there is a way in IM or some other tool like EXIFTOOL to remove just the photoshop meta-data. But again I am not an expert on that.

Perhaps one of the IM developers may be able to shed more light on how to remove just certain meta data such as photoshop data.

You might also report this as a bug, especially since when you convert to tiff while changing the density, it still remains as 300 in IM. Verify it for yourself and then post as a bug along with your problem with saving as jpg.

convert tiff1.tif -density 150 tiff1_150.tif
Last edited by fmw42 on 2012-03-22T09:56:01-07:00, edited 1 time in total.
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

Thank's for the help... I'll do that.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

The other approach to explore might be to somehow extract the clip data, use -strip -density 150 to process the image, then somehow add the clip data back. But again I don't know if/how the latter step would be done.

See -set and +set at http://www.imagemagick.org/script/comma ... 0f6c03#set

I have not tried this, however.
eafalcao
Posts: 11
Joined: 2012-03-20T08:31:03-07:00
Authentication code: 8675308

Re: TIF to JPG, DPI and Clipping Path

Post by eafalcao »

Tif to Tif it's ok. Only fails when is Tif to Jpg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF to JPG, DPI and Clipping Path

Post by fmw42 »

eafalcao wrote:Tif to Tif it's ok. Only fails when is Tif to Jpg.
Not for me using IM.


convert 1tif1.tif -density 150 tif1_150.tif

identify -verbose tif1_150.tif
Image: tif1_150.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 952x3424+0+0
Resolution: 300x300
Print size: 3.17333x11.4133
Units: PixelsPerInch

Photoshop (under Image -> Image Size) also shows 300 dpi for me on my old PS CS
Post Reply