Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 10-04-2022, 07:35 PM   #1
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Disappearing images (png converted to jpg)

I have quite a few books that are very large - in the hundreds of mb, in some cases.

I've worked out how to use ImageMagick to convert the png files (which are nearly always - perhaps always - used in the books in question, rather than jpegs) into jpg format, and then delete the png files from the book, and finally import the jpg files into the book.

Trouble is, although all of the new jpg image files appear in the Calibre editor exactly where the old png files did, when I open up the book they're all (apart from the cover image) completely blank - just showing "img" at the top.

Do I have to somehow re-link each image with its location within the book? If so, how... ?
Liudprand is offline   Reply With Quote
Old 10-04-2022, 07:36 PM   #2
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
(Just to be clear, the reason I'm converting them to jpg is that Calibre seems to be able to compress them much more easily and quickly, as opposed to png files.)
Liudprand is offline   Reply With Quote
Advert
Old 10-04-2022, 08:54 PM   #3
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,552
Karma: 84810789
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
The calibre editor has a "Replace image with file" function that can replace an image and link the new one into the book properly.
jhowell is offline   Reply With Quote
Old 10-04-2022, 09:39 PM   #4
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Quote:
Originally Posted by jhowell View Post
The calibre editor has a "Replace image with file" function that can replace an image and link the new one into the book properly.
Right. But if there are tons of images in a book (which is usually the case, for obvious reasons, in the books I'm talking about), is there a way to replace the images other than doing it one by one?
Liudprand is offline   Reply With Quote
Old 10-04-2022, 09:42 PM   #5
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 36,531
Karma: 146059340
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Liudprand View Post
Right. But if there are tons of images in a book (which is usually the case, for obvious reasons, in the books I'm talking about), is there a way to replace the images other than doing it one by one?
You could replace the image files and then do a search replace on .png and replace it with .jpg in the html files.

This does require replacing all .png file with their .jpg version.
DNSB is online now   Reply With Quote
Advert
Old 10-04-2022, 10:01 PM   #6
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,161
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by Liudprand View Post
Trouble is, although all of the new jpg image files appear in the Calibre editor exactly where the old png files did, when I open up the book they're all (apart from the cover image) completely blank - just showing "img" at the top.

Do I have to somehow re-link each image with its location within the book? If so, how... ?
Yes, you have to relink each image you replace. See the screenshot below.
For each image you replace, you need to find the corresponding link in the html files and adjust the filename so it points to the new image.

If you had used the "replace image with file..." option from the context menu on the image file, this would have happened automatically, but if the image size is different, and you specified width and height (as shown in the screenshot), then that would need to be changed manually.

Is there a way to batch change files? Not that I am aware of.
Attached Thumbnails
Click image for larger version

Name:	image.jpg
Views:	66
Size:	99.3 KB
ID:	196987  
Karellen is online now   Reply With Quote
Old 10-04-2022, 11:30 PM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,996
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Bulk rename all the files to .jpg using the bulk rename tool in the editor. That will update all the links. Then use your scsript to actually convert the files to real jpg.
kovidgoyal is offline   Reply With Quote
Old 10-05-2022, 09:54 AM   #8
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Bulk rename all the files to .jpg using the bulk rename tool in the editor. That will update all the links. Then use your scsript to actually convert the files to real jpg.
Thanks very much for this.

I did as you suggested, but I still have blank spaces in the book where all of the images should be.
Liudprand is offline   Reply With Quote
Old 10-05-2022, 10:05 AM   #9
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Quote:
Originally Posted by Liudprand View Post
Thanks very much for this.

I did as you suggested, but I still have blank spaces in the book where all of the images should be.
Actually, ignore that! I tried again and it worked perfectly. Must have missed something out the first time... Thanks again.
Liudprand is offline   Reply With Quote
Old 10-05-2022, 11:06 AM   #10
Liudprand
Zealot
Liudprand began at the beginning.
 
Posts: 129
Karma: 10
Join Date: Nov 2021
Device: Kobo Libra 2
Actually, one follow-up question - which I realise might be asking too much!

Some of the books I have contain literally hundreds of images, some of which are already in jpg form, distributed apparently randomly throughout.

This makes it very difficult to select just the non-jpg images, other than manually. If I accidentally include just one jpg image when I'm trying to change the file extensions in bulk, it gives me an error message because, in that one case, I'm making a request that is circular. So, is there a way to sort the images in the left-hand panel by type, rather than in terms of their position in the book? Then it would be relatively easy to select just the non-jpg images.

Thanks again!
Liudprand is offline   Reply With Quote
Old 10-05-2022, 01:01 PM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,996
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No there is no way to sort the file browser
kovidgoyal is offline   Reply With Quote
Old 10-05-2022, 03:00 PM   #12
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,950
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A

DANGER backup

REGEX the OPF section
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PNG to JPG ableal Calibre 12 10-04-2022 07:39 PM
Convert epup3 pages to consecutive image file(JPG,PNG...) tai0909 ePub 5 10-14-2019 05:19 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 08:10 PM.


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