|
|
View Full Version : prflrf source code?
I've been working on a txt2lrf program which
could work with any encoding.
The tool would first render the txt file, save the result to a gif image, and then embed all the GIFs to a LRF file.
I've studied the makelrf source code, and got everything almost done. But what I found was, the antialiased font doesn't work very well on the Sony Reader - not as good as pdflrf.
It seems pdflrf uses an Image Edge Enhancement algorithm to make the text 'bolder'. (I tried Sobel operator, but it didn't work very well.)
As I'm not quite familiar with image processing, I wonder if the source of pdflrf is available so that I can refer to it. I've been searching over the internet all day, but couldnt find it. Anybody could help?
nrapallo 04-19-2008, 10:40 PM I've been working on a txt2lrf program which
could work with any encoding.
The tool would first render the txt file, save the result to a gif image, and then embed all the GIFs to a LRF file.
I've studied the makelrf source code, and got everything almost done. But what I found was, the antialiased font doesn't work very well on the Sony Reader - not as good as pdflrf.
It seems pdflrf uses an Image Edge Enhancement algorithm to make the text 'bolder'. (I tried Sobel operator, but it didn't work very well.)
As I'm not quite familiar with image processing, I wonder if the source of pdflrf is available so that I can refer to it. I've been searching over the internet all day, but couldnt find it. Anybody could help?
The python source code for PDFRead 1.8.2 is located here (http://www.mobileread.com/forums/attachment.php?attachmentid=12243&d=1208523338). The main thread for PDFRead 1.8 can be found starting here (http://www.mobileread.com/forums/showthread.php?t=21906).
The image routines used therein are supported by the Python Imaging Library (PIL) (http://www.pythonware.com/products/pil/).
In particular, to thicken the text, I use the following routine, in the module 'process.py':""" perform image dilation """
def dilate(image):
p('DILATE ')
return image.filter(ImageFilter.MinFilter)
Another more simplistic method (not used in PDFRead) would be a simple blur of the image (perhaps at a higher dpi) as follows:""" perform image blur """
def dilate_blur(image):
p('DILATE_BLUR ')
return image.filter(ImageFilter.BLUR)
Perhaps these will help.
Thanks for your reply. I tried the filters in Python, but doesnt seem to work very well.
ImageFilter.Min makes it far too bold, and some of the strokes would overlap. ImageFilter.BLUR simply doesnt work. It's so blurred that I guess nobody could even figure out what's written.
I hope the filter could work out as the way for the Image Edge Enhancement filter in Photoshop CS2.
nrapallo 04-21-2008, 10:17 AM Thanks for your reply. I tried the filters in Python, but doesnt seem to work very well.
ImageFilter.Min makes it far too bold, and some of the strokes would overlap. ImageFilter.BLUR simply doesnt work. It's so blurred that I guess nobody could even figure out what's written.
I hope the filter could work out as the way for the Image Edge Enhancement filter in Photoshop CS2.
If the resulting image is too bold, then your source image is at a very low dpi. Can you create a larger picture, then reduce it "at the end" to fit the ereader's display size?
Also, Image Edge Enhancement is a 'sharpening' method which has the opposite effect of reducing the width of the text, not widening it.
What you can try then is make it bold first, then sharpen it afterwards.
As they say, a picture worths 1000 words. I think it's better for me to post the pictures here. The 0.gif is what I've generated, and the test.gif is what I got from Photoshop.
They're with different text contents and in Simplified Chinese. But I think you can see the idea behind it. I don't think bolding the font would work, as Photoshop doesnt need to do so.
http://www.peidaqi.com/0.gif
http://www.peidaqi.com/test.gif
nrapallo 04-22-2008, 10:28 AM OK, I took your 0.gif, rescaled it larger by 300%, blurred it and shrunk it back by 33% (I couldn't do 33.33333%) and got the following 0-new.gif.
Is this better than the photoshop one, on your ereader?
If it is, then you should perform your image manipulations at a higher dpi (dots per inch), then resize back down to your final size.
|