Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-05-2016, 05:58 AM   #1
epubli
Member
epubli began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Nov 2012
Device: Pocketbook611
Rescale images retrieved by GoComics recipe

Hi,

could someone help me with the builtin GoComics recipe. I a trying to download the Agnes comic (http://www.gocomics.com/agnes). I would like to rescale the images to max dimensions of 800x600 preserving the aspect ratio. The downloaded comic images are PNG with about 900x300pixels.

I have unsuccessfully tried to set
Code:
scale_news_images = (800, 600)
This resulted in distorted png images with 800x600 size.


I also tried to modify the images in postprocess_html function, but the image object used by calibre does not seem to have the .thumbnail method explained at stackoverflow (http://stackoverflow.com/questions/2...s-aspect-ratio).

My third try was the following code code for postprocess_html I found in another recipe. This code happens to create only cropped images:

Code:
    
def postprocess_html(self, soup, first):
        maxwidth=800
        maxheight=600
        for tag in soup.findAll(lambda tag: tag.name.lower()=='img' and tag.has_key('src')):
            iurl = tag['src']
            img = Image()
            img.open(iurl)
            left=0
            top=0
            border_color='#ffffff'
            if (width > maxwidth) :
                newheight= float(height) / width * maxwidth
                canvas = create_canvas(maxwidth, newheight,border_color)
            canvas.compose(img, left, top)
            #img = canvas
            #img.save(iurl)
            canvas.save(iurl)
            width, height = canvas.size
            print '***NEW img width is: ', width, 'height is: ', height
        return soup
Another related question. When I test my recipe with "ebook-convert testgocomics.recipe testgocomic --test -vv", it
fetches the comics using several threads which makes reading the debugging output almost impossible. How can I limit to 1 thread ?

Thanks for your help !
epubli is offline   Reply With Quote
Old 05-05-2016, 06:58 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,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
simultaneous_downloads = 1

And if I were you I wouldn't bother cropping the images manually, just use

extra_css = 'img { max-width: 800; max-height: 600}'

and let the display engine take care of it for you -- unless you intend to read these comics on something very primitive.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GoComics Recipe.... gabby98 Recipes 4 06-10-2013 02:38 PM
GoComics After Merger - New "Feeds" ListWith the ensuing merger of GoComics and Comic BRGriff Recipes 7 07-25-2012 05:23 PM
gocomics recipe not longer working in full Andreas Recipes 8 05-20-2011 10:25 AM
Recipe produces no Images - Please help. Onecanuck Recipes 6 12-16-2010 08:29 PM
The Economist recipe images are too large santino1980 Recipes 4 11-01-2010 03:35 PM


All times are GMT -4. The time now is 06:19 PM.


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