Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-21-2022, 08:30 PM   #1
ableal
Enthusiast
ableal began at the beginning.
 
Posts: 28
Karma: 10
Join Date: May 2009
Device: BeBook (2009), Kobo Clara HD (2018), Kobo Libra 2 (2022)
PNG to JPG

Sometimes ebooks will be embiggened with large PNG images of photos which should have been much smaller JPGs

The Calibre editor built-in "compress image" tool does not offer that conversion, and it seems to me, after some search, that no plug-in does it either.

I would not mind at all being corrected on this
ableal is offline   Reply With Quote
Old 03-26-2022, 12:06 AM   #2
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by ableal View Post
Sometimes ebooks will be embiggened with large PNG images of photos which should have been much smaller JPGs
If you're familiar with command line tools, you could do a lossy png optimization with pngquant.
Shameless plug: I created a Sigil plugin for lossy (and lossless) .png optimization that uses pngquant for lossy optimization.
Doitsu is offline   Reply With Quote
Advert
Old 03-26-2022, 08:41 AM   #3
compurandom
Guru
compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.compurandom ought to be getting tired of karma fortunes by now.
 
Posts: 919
Karma: 417282
Join Date: Jun 2015
Device: kobo aura h2o, kobo forma
Quote:
Originally Posted by ableal View Post
Sometimes ebooks will be embiggened with large PNG images of photos which should have been much smaller JPGs
It's not PNG vs JPG that makes it big, it is quality and resolution.

JPG is generally lower quality. A PNG of the same quality as the JPG likely would be smaller than the JPG.
compurandom is offline   Reply With Quote
Old 03-26-2022, 11:39 AM   #4
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 387
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
I often see this. Given the quality of images on an e-ink reader, I don't care much about absolute image quality. On the Kindle or Kobo I usually can't tell the difference after I seriously change and compress images. I use ImagMagick from the command line:

1. Open the book in the editor, export all the png images to a working directory.
2. In that directory, run mogrify -format jpg *.png from a terminal, of course ImageMagick has to be installed.
3. Back in the editor, delete all the png files and import all the jpg files you made
4. In search & replace, look for .png and replace with .jpg in all text files
5. Run compress images lossily at a factor of 50.

That actually takes only a minute or two after you have done it a couple of times. When you are dealing with 40 or 50 or more images, it saves hours compared to one-by-one processing.
retiredbiker is offline   Reply With Quote
Old 03-26-2022, 01:36 PM   #5
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,608
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by compurandom View Post
It's not PNG vs JPG that makes it big, it is quality and resolution.

JPG is generally lower quality. A PNG of the same quality as the JPG likely would be smaller than the JPG.
JPG also doesn't support transparency if that's important to you. (JPEG2000 does -- shame it isn't more widely used.)
ownedbycats is offline   Reply With Quote
Advert
Old 03-27-2022, 05:57 AM   #6
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,154
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Most ereaders don't support PNG Transparency and dark mode can be a problem.

Line art, graphic presentations & some non-photographic images can look worse in JPG or even in extreme cases be larger. But natural images can look fine in jpeg with a big file space saving.

Transparency is for fancy websites, or multimedia or apps. It should usually be replaced by white for images to be used on paper or in real eBooks.
Quoth is offline   Reply With Quote
Old 03-27-2022, 08:45 PM   #7
ableal
Enthusiast
ableal began at the beginning.
 
Posts: 28
Karma: 10
Join Date: May 2009
Device: BeBook (2009), Kobo Clara HD (2018), Kobo Libra 2 (2022)
Quote:
Originally Posted by retiredbiker View Post
I often see this. Given the quality of images on an e-ink reader, I don't care much about absolute image quality. On the Kindle or Kobo I usually can't tell the difference after I seriously change and compress images. I use ImagMagick from the command line:

1. Open the book in the editor, export all the png images to a working directory.
2. In that directory, run mogrify -format jpg *.png from a terminal, of course ImageMagick has to be installed.
3. Back in the editor, delete all the png files and import all the jpg files you made
4. In search & replace, look for .png and replace with .jpg in all text files
5. Run compress images lossily at a factor of 50.

That actually takes only a minute or two after you have done it a couple of times. When you are dealing with 40 or 50 or more images, it saves hours compared to one-by-one processing.
Thanks, yeah, I'm with with you on all points, though I'm squeamish and usually stick to 85% lossy. This should work for me, no problem with CLI tools, started there donkey's years ago. Got WSL on Windows for some occasional Unix mojo.

Step 3 is the key, hadn't thought of that. Replacing manually each one of a few dozen images in a particular large book tripped my lazyness threshold

Many thanks.
ableal is offline   Reply With Quote
Old 03-27-2022, 08:57 PM   #8
ableal
Enthusiast
ableal began at the beginning.
 
Posts: 28
Karma: 10
Join Date: May 2009
Device: BeBook (2009), Kobo Clara HD (2018), Kobo Libra 2 (2022)
Thanks also to those who mentioned the quality and transparency issues, but that's not at play in the case that made me post.

It's particularly egregious, there's a bunch of photos as pngs, and to add insult to injury, they are shown on page smaller than original size ...
ableal is offline   Reply With Quote
Old 03-28-2022, 07:45 AM   #9
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,154
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by ableal View Post
Thanks also to those who mentioned the quality and transparency issues, but that's not at play in the case that made me post.

It's particularly egregious, there's a bunch of photos as pngs, and to add insult to injury, they are shown on page smaller than original size ...
Set a % width if a landscape image. Not sure about portrait. I set 90% wide & keep aspect in the Wordprocessor before export to docx and conversion to epub2. I make mobi, dual mobi or azw3 from the epub.
Quoth is offline   Reply With Quote
Old 03-30-2022, 10:28 AM   #10
ableal
Enthusiast
ableal began at the beginning.
 
Posts: 28
Karma: 10
Join Date: May 2009
Device: BeBook (2009), Kobo Clara HD (2018), Kobo Libra 2 (2022)
Just to confirm that retiredbiker's kindly provided recipe works flawlessly.

I managed to create a snag - the png photos were dumped in a folder three deep (hmtl?/?/images), and I imported the jpegs back directly, instead of in a folder. Being lazy, I just fixed the paths by replacing prefix strings, after doing the same for the file extensions.
ableal is offline   Reply With Quote
Old 10-04-2022, 04:46 PM   #11
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 126
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Quote:
Originally Posted by retiredbiker View Post
I often see this. Given the quality of images on an e-ink reader, I don't care much about absolute image quality. On the Kindle or Kobo I usually can't tell the difference after I seriously change and compress images. I use ImagMagick from the command line:

1. Open the book in the editor, export all the png images to a working directory.
2. In that directory, run mogrify -format jpg *.png from a terminal, of course ImageMagick has to be installed.
3. Back in the editor, delete all the png files and import all the jpg files you made
4. In search & replace, look for .png and replace with .jpg in all text files
5. Run compress images lossily at a factor of 50.

That actually takes only a minute or two after you have done it a couple of times. When you are dealing with 40 or 50 or more images, it saves hours compared to one-by-one processing.
I know this is from a while ago, but I'm hoping it'll be useful for me, but ran into a problem. I'm not too familiar with command-line processes, but when I tried to do what I think you're suggesting in #2, I just get the response:
"'mogrify' is not recognized as an internal or external command,
operable program or batch file."
I've got ImageMagick installed, but obviously there's something I'm missing... Any tips gratefully received.
Liudprand is offline   Reply With Quote
Old 10-04-2022, 06:04 PM   #12
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 387
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
Quote:
"'mogrify' is not recognized as an internal or external command,
operable program or batch file."
I've got ImageMagick installed, but obviously there's something I'm missing... Any tips gratefully received.
This will be a problem with the ImageMagick installation - not in your path or something. If you are on Ubuntu/Linux try the command
:~$ which mogrify
and see if you get
/usr/bin/mogrify

I'm no expert but ImageMagick is a complex beastie and as I recall I had to mess with it for a while to get it working a few years ago, but I can't recall what it needed. The OS forums are your friends here!
retiredbiker is offline   Reply With Quote
Old 10-04-2022, 07:39 PM   #13
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 126
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Actually I worked out the problem from a youtube video, which told me to use:
"magick mogrify... [etc.]"
rather than starting with "mogrify". That worked.

Trouble is, I have another problem now. I've created a new thread about it, here: https://www.mobileread.com/forums/sh...62#post4263062

I'd certainly be grateful if you could offer any further advice...
Liudprand is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert epup3 pages to consecutive image file(JPG,PNG...) tai0909 ePub 5 10-14-2019 05:19 AM
KindleGallery: a nice png/jpg image viewer for Paperwhite (1 & 2) and Touch Aeris Kindle Developer's Corner 4 11-04-2013 11:36 AM
Replace all jpg with png with transparent background? Claghorn Recipes 0 08-16-2012 12:14 PM
Touch Converting multiple .jpg/.png into ePub for Manga Gater Kobo Reader 11 01-08-2012 07:28 AM


All times are GMT -4. The time now is 03:12 AM.


MobileRead.com is a privately owned, operated and funded community.