Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-29-2018, 01:13 AM   #1
dr_Fell
Junior Member
dr_Fell began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2016
Device: Cybook Odyssey
Thumbs up [solved] AZW3 to EPUB conversion: images cropped (Cybook Odyssey)

Hello, I have tried to solve this for few hours and I am stuck.

I am trying to convert my book from amazon (Java: The Complete Reference) to epub so I can read it on my Cybook Odyssey. After conversion it seems that the images are cropped (at least from left/right) by few pixels. Since code examples are in image (jpg) form it makes the book unusable, because important elements, like semicolons, parentheses etc. are often located near the borders.

I tried to limit max width with
Code:
div span img
{
 max-width: 90% !important;
}
or
Code:
div span img
{
 max-width: 530px;
}
Effect was visible, the image was smaller, but the problem remains (few pixels cropped on the sides). Problem is visible only on my Cybook Odyssey, Calibre Viewer displays those images without problem.

I think that I can eventually use some workaround by processing those images and adding few more pixels on each border - but I don't know how to access them.


Solution:
I downloaded images using book editor, edited them, then put it back to the book. It didn't work well with epub (don't know why - maybe I did something wrong), but it works with original AZW3 file.

I added 5px white border to images using ImageMagick tools (workaround so my reader just cuts those white border and not the actual image). Additionally I adjusted size and sharpened all images, so my reader won't have to change resolution on the fly (for quality and readability). I also set a bit of negative left margins during conversion, so that the images could be a bit wider.
The code is now much more readable than in the original files provided by Amazon .

If this can be helpful for anyone, here are command line examples on how to batch change size and sharpeness:

Code:
 magick mogrify -format bmp *.jpeg    //convert every jpeg image to bmp for further loseless processing

magick mogrify -filter Mitchell -resize 550x730^> -format bmp *.bmp  //downscale images that are wider than 550px or higher than 730px, leaving smaller images untouched

magick mogrify -bordercolor white -border 5x3 -unsharp 0x1.1+2+0 -format jpeg *.bmp     //add white border and sharpeness to every bmp image and save back as jpeg
and the margins:

Code:
div span img {
 margin-left:-15px;
}

Last edited by dr_Fell; 06-30-2018 at 03:10 AM. Reason: Solution found
dr_Fell is offline   Reply With Quote
Old 06-29-2018, 01:25 AM   #2
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,772
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre does not crop images during conversion, this is a bug in the reader you are using. And if you want to access the images, simply edit the azw3 using the calibre editor or use the unpack book tool.
kovidgoyal is offline   Reply With Quote
Old 06-29-2018, 04:59 AM   #3
dr_Fell
Junior Member
dr_Fell began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2016
Device: Cybook Odyssey
I managed to download images from book, add small white border to every one of them, then I deleted original images in Calibre editor and uploaded modified images with same names. Unfortunately new images are not visible... What am I doing wrong?
dr_Fell is offline   Reply With Quote
Old 06-29-2018, 05:10 AM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,645
Karma: 127838196
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
What you need to do to stop the images from being modified is to change the output profile to TABLET. By setting the output profile to tablet, Calibre will not resize the images at all.
JSWolf is offline   Reply With Quote
Old 06-29-2018, 07:51 AM   #5
dr_Fell
Junior Member
dr_Fell began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2016
Device: Cybook Odyssey
Quote:
Originally Posted by JSWolf View Post
What you need to do to stop the images from being modified is to change the output profile to TABLET. By setting the output profile to tablet, Calibre will not resize the images at all.
Hmm, I'd say this is not a problem with images resized by calibre, but rather badly rendered by my device. I tried what You suggested and nothing has changed (images cropped on the right and left and sometimes damaged at bottom).

If only I could replace images from epub with my modified versions, that would probably fix the problem. Any idea why this doesn't work? New images being a bit bigger than old versions (14 points wider and 6 points higher) could be the cause?
dr_Fell is offline   Reply With Quote
Old 06-29-2018, 08:51 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,908
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by dr_Fell View Post
Hmm, I'd say this is not a problem with images resized by calibre, but rather badly rendered by my device. I tried what You suggested and nothing has changed (images cropped on the right and left and sometimes damaged at bottom).
It would be a good idea to post the code as well as the styles for us to look at or try. Or use the Scramble plugin to generate a version of the book you can post.
Quote:
If only I could replace images from epub with my modified versions, that would probably fix the problem. Any idea why this doesn't work? New images being a bit bigger than old versions (14 points wider and 6 points higher) could be the cause?
Try using "Unpack book". That will unzip the book into a folder. You can then replace the images and calibre can repack it.
davidfor is offline   Reply With Quote
Old 06-30-2018, 03:03 AM   #7
dr_Fell
Junior Member
dr_Fell began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2016
Device: Cybook Odyssey
Thank You all for help! Problem seem to be solved. I have paid a lot of money (at least for me) for that book and I am glad I can use it now

I downloaded graphics, edited them, then put it back to the book. It didn't work well with epub (don't know why), but it works with original AZW3 file.

I added 5px white border to images using ImageMagick tools (workaround so my reader just cuts those white border and not the actual image). Additionally I adjusted size and sharpened all images, so my reader won't have to change resolution on the fly (for quality and readability). I also set a bit of negative left margins during conversion, so that the images could be a bit wider.
The code is now much more readable than in the original files provided by Amazon .

If this can be helpful for anyone, here are command line examples on how to batch change size and sharpeness:

Code:
 magick mogrify -format bmp *.jpeg    //convert every jpeg image to bmp for further loseless processing

magick mogrify -filter Mitchell -resize 550x730^> -format bmp *.bmp  //downscale images that are wider than 550px or higher than 730px, leaving smaller images untouched

magick mogrify -bordercolor white -border 5x3 -unsharp 0x1.1+2+0 -format jpeg *.bmp     //add white border and sharpeness to every bmp image and save back as jpeg
and the margins:

Code:
div span img {
 margin-left:-15px;
}

@davidfor - what do You mean by "post the code"? What code besides CSS styles can I post here? Debugger output?
I couldn't find "unpack book" feature - where is it located? This could be much faster than deleting and then uploading almost 2000 files using book editor...

Last edited by dr_Fell; 06-30-2018 at 03:12 AM.
dr_Fell is offline   Reply With Quote
Old 06-30-2018, 03:44 AM   #8
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,908
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by dr_Fell View Post
@davidfor - what do You mean by "post the code"? What code besides CSS styles can I post here? Debugger output?
The HTML code that actually puts the image in the book. There could be styles on it or something else that positions the images badly.
Quote:
I couldn't find "unpack book" feature - where is it located? This could be much faster than deleting and then uploading almost 2000 files using book editor...
For me, it is on the right-click menu in the book list. But, you might need to add it using the toolbar configuration in the preferences.
davidfor is offline   Reply With Quote
Old 06-30-2018, 12:31 PM   #9
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,689
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by dr_Fell View Post

@davidfor - what do You mean by "post the code"? What code besides CSS styles can I post here? Debugger output?
I couldn't find "unpack book" feature - where is it located? This could be much faster than deleting and then uploading almost 2000 files using book editor...
'U" is the shortcut, even if there is no menu item
theducks is offline   Reply With Quote
Old 07-01-2018, 05:17 PM   #10
dr_Fell
Junior Member
dr_Fell began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2016
Device: Cybook Odyssey
Indeed, I had to add this option. Also, thanks for the shortcut.
dr_Fell is offline   Reply With Quote
Reply

Tags
azw3, calibre, conversion, cybook, epub

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Images from AZW3 Lonely Planet books are downsampled in ePub output wealthychef Conversion 3 05-27-2018 10:34 AM
EPUB to MOBI (AZW3). Black SVG images with CSS styles uka Conversion 6 03-04-2018 09:50 PM
Calibre Epub to AZW3: Scale images to fit Voyage/PW? cw30000 Conversion 3 07-08-2017 12:10 AM
Images going from ePub tu mobi or azw3 format valegar44 Kindle Formats 2 09-09-2014 01:07 AM
Conversion from epub to azw3 Joy736 Conversion 12 01-01-2013 11:00 AM


All times are GMT -4. The time now is 09:48 AM.


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