Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generated images is broken #199

Open
latel opened this issue Jan 31, 2024 · 12 comments
Open

generated images is broken #199

latel opened this issue Jan 31, 2024 · 12 comments

Comments

@latel
Copy link

latel commented Jan 31, 2024

system infomation

$ uname -a
Linux VM_64_3_centos 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ yum install GraphicsMagick
$ yum install ghostscript

$ gm -help
GraphicsMagick 1.3.38 2022-03-26 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2022 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Usage: gm help command [options ...]

Where commands include:
    animate - animate a sequence of images
      batch - issue multiple commands in interactive or batch mode
  benchmark - benchmark one of the other commands
    compare - compare two images
  composite - composite images together
    conjure - execute a Magick Scripting Language (MSL) XML script
    convert - convert an image or sequence of images
    display - display an image on a workstation running X
       help - obtain usage message for named command
   identify - describe an image or image sequence
     import - capture an application or X server screen
    mogrify - transform an image or sequence of images
    montage - create a composite image (in a grid) from separate images
       time - time one of the other commands
    version - obtain release version

$ convert -version
Version: ImageMagick 6.9.10-68 Q16 x86_64 2024-01-12 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(3.1) 
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps rsvg tiff wmf x xml zlib

Codes

import { fromBuffer } from "pdf2pic";

const pdfFile = '3b91b401-cab8-4b0e-9b73-5a9281910de4.pdf';
const pdfBuffer = fs.readFileSync(pdfPath);
const convert = fromBuffer(pdfBuffer, {
    density: 300,
    format: "png",
    width: 2481 / 2,
    height: 3508 / 2,
    saveFilename: "untitled",
    savePath: path.resolve('./saved-images'),
});
const resolves = await convert.bulk(-1, { responseType: "image" });

result image
1

@mskec
Copy link
Collaborator

mskec commented Jan 31, 2024

Hi @latel, can you try installing the latest GraphicsMagick 1.3.42?

@latel
Copy link
Author

latel commented Feb 2, 2024

I tried 1.3.42 through compiling source code, still not working

gm -help
GraphicsMagick 1.3.42 2023-09-23 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2023 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Usage: gm help command [options ...]

Where commands include:
      batch - issue multiple commands in interactive or batch mode
  benchmark - benchmark one of the other commands
    compare - compare two images
  composite - composite images together
    conjure - execute a Magick Scripting Language (MSL) XML script
    convert - convert an image or sequence of images
       help - obtain usage message for named command
   identify - describe an image or image sequence
    mogrify - transform an image or sequence of images
    montage - create a composite image (in a grid) from separate images
       time - time one of the other commands
    version - obtain release version

@latel
Copy link
Author

latel commented Feb 2, 2024

May be I should install a newer imagemagick version?

@latel
Copy link
Author

latel commented Feb 2, 2024

I compile imagemagick 7.1.1.-28, still not working

$ convert -version
Version: ImageMagick 7.1.1-28 (Beta) Q16-HDRI x86_64 0225ac41a:20240121 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib ltdl zlib
Compiler: gcc (8.3)

here's converted image
upload_1706857268496 0 5964799179231548 0 pdf0

@yakovmeister
Copy link
Owner

@latel have you tried it with a different pdf file? can you send us the pdf you are trying to convert so we can also check.

@awolad
Copy link

awolad commented Mar 6, 2024

@yakovmeister I also had the same issue. I tried in the AWS Lambda. Here is the PDF: https://drive.google.com/file/d/1ReoTNHr6wLiFFWPBNaJmLR2_oxwjLdBm/view?usp=sharing

Broken images:

image

@latel
Copy link
Author

latel commented Mar 14, 2024

@latel have you tried it with a different pdf file? can you send us the pdf you are trying to convert so we can also check.

Sorry, my pdf is copyrighted, so I can't put it public, but I can try yout experiments.

@yakovmeister
Copy link
Owner

@yakovmeister I also had the same issue. I tried in the AWS Lambda. Here is the PDF: https://drive.google.com/file/d/1ReoTNHr6wLiFFWPBNaJmLR2_oxwjLdBm/view?usp=sharing

Broken images:

image

@awolad I can confirm that the pdf link you sent me atleast worked on default option bulk convert.
image

can you also share the options you used for converting?

@yakovmeister
Copy link
Owner

Sorry, my pdf is copyrighted, so I can't put it public, but I can try yout experiments.

@latel can you try not setting the density, width and height options just to check if it would properly convert this time?

@awolad
Copy link

awolad commented Mar 15, 2024

@yakovmeister I also had the same issue. I tried in the AWS Lambda. Here is the PDF: https://drive.google.com/file/d/1ReoTNHr6wLiFFWPBNaJmLR2_oxwjLdBm/view?usp=sharing
Broken images:
image

@awolad I can confirm that the pdf link you sent me atleast worked on default option bulk convert. image

can you also share the options you used for converting?

Sure! I used the default options, but my environment was AWS Lambda. It worked for me on the local machine as well.

@racso-dev
Copy link

Did anyone solve this?
I'm facing a very similar issue where converting pdf to png works fine on my local machine, and when running in AWS, the output image is just blank, or if I use the buffer the image is exactly like the image mentionned initially in the issue

@GautierT
Copy link

Hi. Same issue. Image are broken when using pdf2pic in docker with ghostscript & graphicsmagick installed from apt-get
Image are okay when trying in my local machine (ghostscript & graphicsmagick installed with brew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants