Page 1 of 1

trouble making thumbnail for PDF

Posted: 2012-11-09T03:30:58-07:00
by bugbear
I am trying to make thumbnails. My (original) command was

Code: Select all

convert -define pdf:use-cropbox=true -density 36x36 'sample.pdf'[0]' -strip  -size 128x128 -filter point -resize 512x512'>' -filter cubic -resize 128x128'>' -colorspace RGB -sharpen 3 -density 72x72 -quality 85 jpg:thumb.jpg
This was giving a thumb which was pretty much negated (including BLACK background, not white).

A bit of elimination allowed me to simplify and isolate the problem:

Code: Select all

convert sample.pdf ras.tif
convert ras.tif -filter cubic -resize 512x512'>' jpg:v.jpg
also shows the problem.

Here's the output of identify -verbose ras.tif with the histogram removed:

Code: Select all

Image: ras.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 904x1105+0+0
  Resolution: 72x72
  Print size: 12.5556x15.3472
  Units: Undefined
  Type: TrueColorMatte
  Base type: TrueColor
  Endianess: MSB
  Colorspace: sRGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 65535 (1)
      mean: 64579.4 (0.985419)
      standard deviation: 7511.44 (0.114617)
      kurtosis: 65.9126
      skewness: -8.16061
    Green:
      min: 0 (0)
      max: 65535 (1)
      mean: 64840.9 (0.989409)
      standard deviation: 5079.34 (0.0775057)
      kurtosis: 75.4982
      skewness: -8.25455
    Blue:
      min: 0 (0)
      max: 65535 (1)
      mean: 65019.3 (0.992131)
      standard deviation: 4120.67 (0.0628775)
      kurtosis: 129.093
      skewness: -10.448
    Alpha:
      min: 0 (0)
      max: 65535 (1)
      mean: 1323.58 (0.0201966)
      standard deviation: 9045.78 (0.13803)
      kurtosis: 45.0837
      skewness: -6.83194
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 64662.8 (0.986691)
      standard deviation: 6727.32 (0.102652)
      kurtosis: 75.1481
      skewness: -8.55715
  Alpha: srgba(255,255,255,0)   #FFFFFFFFFFFF0000
  Colors: 436
  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: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Compose: Over
  Page geometry: 904x1105+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2012-11-09T10:25:47+00:00
    date:modify: 2012-11-09T10:25:47+00:00
    signature: 6ffdb8c5124c5047cc19075940b5de2196a506274a4444b5ca356a736c435d6e
    tiff:alpha: unassociated
    tiff:document: ras.tif
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 1
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 8.001MB
  Number pixels: 999K
  Pixels per second: 49.95MB
  User time: 0.030u
  Elapsed time: 0:01.019
  Version: ImageMagick 6.7.5-6 2012-08-11 Q16 http://www.imagemagick.org

From my searching, it appears that "Type: TrueColorMatte" and "Colorspace: sRGB"
both have the potential to cause trouble.

BugBear

Re: trouble making thumbnail for PDF

Posted: 2012-11-09T10:59:04-07:00
by fmw42
post a link to you input pdf and ouput jpg.

check the verbose info for your pdf? Is it CMYK? Does it have an alpha channel?

why do you set the density 36x36 that will give poor output quality. Best to use a larger density and then resize smaller afterwards.

Going to tiff does not necessarily explain the pdf issue. You need to analyze the input pdf.

-size 128x128 does nothing in your command line as far as I can see.

Why do you do two resizes? That lowers the quality a little.

Why do you have -colorspace RGB?. If the pdf is CMYK, then best to put the colorspace conversion before reading the input pdf.

Re: trouble making thumbnail for PDF

Posted: 2012-11-12T10:21:58-07:00
by bugbear
fmw42 wrote:post a link to you input pdf and ouput jpg.

check the verbose info for your pdf? Is it CMYK? Does it have an alpha channel?

why do you set the density 36x36 that will give poor output quality. Best to use a larger density and then resize smaller afterwards.

Going to tiff does not necessarily explain the pdf issue. You need to analyze the input pdf.

-size 128x128 does nothing in your command line as far as I can see.

Why do you do two resizes? That lowers the quality a little.

Why do you have -colorspace RGB?. If the pdf is CMYK, then best to put the colorspace conversion before reading the input pdf.
I'm making 128x128 thumbnails for web use. This command is used for all inputs. I'm using 36 DPI since some of the PDFs I'm handling can be up to tabloid size.

I do multiple resizes for performance - note the careful use of different filters, and the ">" argument on geometry.

the -size 128x128 is the old way of controlled the optimsed sub-sampling in the IJG Jpeg decoder.

I do the colorspace conversion so that poorly implemented web browsers never see CMYK, which some of them can't handle.

I do the colorspace conversion after the sub sampling to improve performance.

My problem was indeed an alpha channel, and +matte fixed it.

BugBear