The images generated by the module on my setup are quite blurry and smudgy, even though I've set ImageMagick to 100 percent quality.

Does anyone know what the problem might be, and how I could fix it?

Comments

jtwalters’s picture

Probably need to adjust the density args... this requires a patch.

at line 216 of pdfpreview.module I've added:

  $args['colorspace'] = '-colorspace ' . escapeshellarg('RGB');
  $args['density'] = '-density ' . escapeshellarg('150');
  $args['alpha'] = '-alpha ' . escapeshellarg('Off');
  $args['compose'] = '-compose ' . escapeshellarg('Copy');

Let me know if that helps.

jtwalters’s picture

Note: The density arg won't work unless it is prepended as the first argument (before the pdf file argument)...the default density may not be suitable. You would need to modify the code that calls convert.

Daguntzi’s picture

I've got the same problem and I don't know how to solve it!! Please help!

jtwalters’s picture

Line 227 of 7.x-2.1 is probably responsible for this:

$command = escapeshellarg($source) . ' ' . implode(' ', $args) . ' ' . escapeshellarg($dest);

You need to specify a higher density argument for the resulting image to be sharper. Something like this (untested):

$command = '-density 150 ' . escapeshellarg($source) . ' ' . implode(' ', $args) . ' ' . escapeshellarg($dest);

jakob123’s picture

Status: Active » Needs review
StatusFileSize
new4.04 KB
new4.25 KB

Attached is a patch to make the raster density configurable by the user.
Works fine here, I'm using 300dpi which gives good quality even for large (1024x1024) previews. It's quite slow (several seconds for one PDF!) an uses a lot of RAM, so I would recommend trying 150dpi first.

Please test the patch so this can be set to "reviewed & tested by the community"!

If you don't know how to apply the patch, I have also attached the complete patched "pdfpreview.module" file.

stefan.norman’s picture

I have tested the patch in #5. Solution works fine.
Attaching same patch for 7.x-2.1

pbuyle’s picture

Status: Needs review » Needs work

With commit 1c18fc2 made for #2300203: Remote files not supported, PDF Preview uses _imagemagick_convert instead of _imagemagick_convert_exec(). Preprending options before the input is not possible when using _imagemagick_convert. It's a short-coming of the ImageMagick module itself.

The patch for this issue needs a re-roll for the latest 7.x-2.x branch. Also relevant is the removal of the pdfpreview_quality variable, the general imagemagick_quality variable is now used (thanks to _imagemagick_convert).

nbuonin’s picture

I had this problem as well. What worked for me was changing the image format settings in the manage display menu for the content type.

What I realized was the the module assigned the stock "medium" image format to the generated jpg. The image was essentially being rendered twice, first by ImageMagick and then again by Drupal, resulting in a pretty scuzzy looking image.

I set the image format to none, and then used to containing div to constrain the image to the size needed.

joelstein’s picture

Status: Needs work » Needs review
StatusFileSize
new3.34 KB

Here's a patch which takes the good stuff from #6 and works with the ImageMagick patch at #1022444-3: Some ImageMagick options should precede the source file, which makes it possible to prepend the 'density' option before the source argument.