05-05-2016, 05:58 AM | #1 |
Member
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) 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 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 ! |
05-05-2016, 06:58 AM | #2 |
creator of calibre
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. |
|
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 |