convert multiple jpg to pdf issue

Hi, I have a problem ImageMgick. I’ld like to convert a lot of jpeg files to one pdf file but when I run convert *.jpg output.pdf I get a blank pdf file with white pages but pdf file size is 35MB.
When I import this pdf file to Gimp I can see correct pdf pages but Okular or Adobe Acrobat can not show pages only blakn white pages…

I used ImageMagick under 42.3 and it worked perfectly. What maybe wrong? Can someone help me?

Thanks for help.

Hi,

You can use

convert *.jpg +compress output.pdf

The only problem I can see about that syntax is when you have problematic files *.jpg that starts with a dash. To be safe you can use

convert ./*.jpg +compress output.pdf

My convert version.

convert --version
Version: ImageMagick 7.0.7-34 Q16 x86_64 20180520 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff webp wmf x xml zlib



Unfortunately, recommended command make similar pdf file. It includes blank with “white” pages…

My convert version is same as yours:

convert --version
Version: ImageMagick 7.0.7-34 Q16 x86_64 20180520 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff webp wmf x xml zlib

FWIW

Also on Leap 15.1 with the same version of ImageMagick (7.0.7-34 Q16 x86_64 20180520) and Okular 1.6.3

I’ve just created a pdf file from 6 jpg images (each approx 6 - 8 Mib, using the first syntax given by @jetchisel) and the file is shown correctly in okular, (I don’t have Acrobat) …

Could it possibly be something amiss with your jpg images, are you able to share one?

Hi
Likewise with convert version and Leap 15.1, tested here with multiple jpegs (16 images, 4032x3024, iPhone 6s). On GNOME DE with eog and fired up windows/adobe. All working fine.

As indicated maybe it is the jpeg images?

I don’t understand this… I’ld like to convert natgeo magazine jpg images to one pdf file. I don’t know how can I upload picrures…

I only found for insert a “picture link” but pictures are on my pc…

My detailed information:

ImageMagick 7.0.7-34 Q16 x86_64 20180520
okular 1.6.3

Leap 15.1 x86_64
kernel 4.12.14-lp151.28.36-default
KDE Plasma 5.12.8
KDE Frameworks 5.55.0
Qt version 5.9.7

Intel Xeon E3-1230
16GB RAM
Nvidia GeForce GTX 1050

I made an google drive accont and uploaded two jpg files…

https://drive.google.com/drive/folders/1GSDIdBGkspNPOskUr4qQwq3-w5lz3i9D?usp=sharing

Thanks.

Hmm… Indeed, those two images result in a pdf with blank pages.

https://paste.opensuse.org/view/raw/b2f22f53

If I attempt to open one of those images using the gimp I get this error:

https://paste.opensuse.org/view/raw/6006c0c5

Accepting that error and then exporting the image from gimp as *.jpg and converting to pdf then works.

https://paste.opensuse.org/view/raw/7d4b51c4

Do you think that problem is the jpg files structure?

The story. I bought ten years ago The Complete National Geographic DVD album. 12 dual layer DVDs. It includes all NG magazine from 1888 to 2011. It is an program what includes all scanned page in jpeg.

When Microsoft released Windows 10 the program support finished… I can’t install and use it on Windows 10 or linux with wine. I tought that I import all jpg from DVD’s and convert it to pdf and read it on ebook viewer (Calibre).

Import and export all jpg file in Gimp is an impossible task… you míy think so… cca. 130 years and 12 month/years and 100-170 pages/month …

Do you have any useful idea?

Thank you for your help.

Yes, it seems the images have some funky value set for the dpi…

See this Image resolution out of bounds Message (2002) — Help & Support — gimpusers.com for a brief description.

Do you have any useful idea?

Perhaps use ImageMagick to change the dpi to something valid… if it does that, I’m not too familiar with it’s capabilities. I’ll try and take a look tomorrow (Saturday)…

I had an idea. tannington recommended that need to open and save jpg files with Gimp but it is a horrible work.

I tried to convert jpg files to jpg by convert command and create a pdf. I experienced that it works. I wrote a script to convert and create pdf from all jpg in dir.

for file in *.jpg; do
convert “$file” “${file%.jpg}_1.jpg”
done
convert *_1.jpg output.pdf

It create an correct pdf file.

Thank you for help.

Very good solution. I was still searching for a CLI tool that could adapt dpi, but his is good thinking.
And thanks for reporting how you did it.

Ah… Late to the party!

Good to see your solution.

I’ve just checked anyway, and yes, imagemagick can set the dpi by using the “-density” command.

“The -density option sets an attribute and does not alter the underlying raster image. It may be used to adjust the rendered size for desktop publishing purposes by adjusting the scale applied to the pixels. To resize the image so that it is the same size at a different resolution, use the -resample option.”

I think the problem was jpg’s Color Space was Uncalibrated. After converted it is sRGB. Other jpg’s parameters not changed…

I can run a script all dir and it repair jpgs and create pdf file.

But I’ld like to rename output.pdf finally to “dirname”.pdf but I don’t know how… I work on it…

Thank you for yours help.

The Final (full) solution forrename output.pfd to dirname.pdf and includ the NGM prefix.

File’s name will be NGM_dirname.pdf. This script repairs jpgs and creates this.

for file in *.jpg; do
convert “$file” “${file%.jpg}_1.jpg”
done

convert 1.jpg NGM"${PWD##/}".pdf

rm *_1.jpg

Thank you for your help.

Regards