![]() |
Quote:
Maybe the problem is caused by a leftover ePubTidyTool.json file. You may want to manually delete the following folders and reinstall the plugin. Code:
%localappdata%\sigil-ebook\sigil\plugins_prefs\ePubTidyTool |
It work now. Thanks Doitsu
@CalibUser I add some more fixes :D Code:
#Fixes '…' when PDFd as ... |
I have updated the plugin in the first post to include the latest changes for Greek texts from gipsy.
Thanks for pointing out that it may be necessary to delete any leftover ePubTidyTool.json files, Doitsu. I will add that advice to the epub guide for this plugin when I next update it. |
I have updated the plugin in the first post so that images in an ePub can be resized.
This will require the PILlow image library from https://pypi.python.org/pypi/Pillow/2.9.0 I decided to make the plugin 'beep' if an alphabetical character is inserted in an entry box for image size; as there is not a 'beep' facility within Python I had to produce a 'beep' that is system dependent. I have only been able to test this on Windows 7, hopefully this will work on Linux (I believe it will be necessary to install sox for the 'beep') and Mac systems too. One problem I had with the code for resizing the image was that I could not seem to read the image file using bk.readfile() into a buffer that PILow could process [I experimented with frombytes(), frombuffer() and fromarray()] so I resorted to saving the original image to disc and opening it again under PILow - not an ideal process. The ePub manual in the first post contains instructions on how to use the new feature. |
Quote:
At least, that is what it should do. I will look at the launcher code to make sure that is really what is happening, just in case. I have no idea how data is passed to Pillow but if it wants a file you should be able to use StringIO with with bk.readfile() returns from an image. I will look into this in case a fix is needed. Thanks, KevinH |
Quote:
For example: Code:
from PIL import Image |
Thanks, Doitsu, this method allows me to read an image from an epub into img. After resizing the image, how can I write it back in a format that bk.writefile() can use? I've tried a few approaches including bkimage = BytesIO(self.img ) but without success.
|
Quote:
Code:
from PIL import Image |
Thanks, Doitsu. I will try to get something to work for jpg files when I have more time.
|
Hi,
The launcher code is correct. Doitsu is correct BytesIO is the way to go. Don't forget BytesIO gives a filedescriptor like interface so after writing to it don't forget to do seek(0) with it before trying to read from it after writing. Also when passing in data using BytesIO don't forget to pass in image format type to Image since it can't see a file extension that would convey the image type info. See some examples in Pillow's docs or via a google search for more info. If you run into difficulty, post some code and I'd be happy to figure out what is going on. KevinH |
I have improved the code in the plugin for resizing images so that temporary files are not written to disc (thanks to Doitsu and KevinH) as in my previous version. The updated plugin is in the first post of this thread.
Technical note: As Doitsu pointed out, "img.save() doesn't appear to work with jpg as the file format." According to information on the internet, the format of the jpg file is the same as for jpeg (early versions of Windows could not handle four character extensions as could other OS, so jpg was used as an extension for Windows. As modern Windows can handle four character extensions this is no longer a problem and it seems that Python uses jpeg only, so by treating jpg files as jpeg files, I have made the plugin work with jpg file extensions). |
Hi,
When using BytesIO() there is no filename or extension. Therefore you must tell the Image routine the type of image you are reading in or saving. These are not the same as file extensions. The format for the .jpg, .jpeg, etc file extension is provided by the value "JPEG". So to save a jpeg (.jpg) image to a BytesIO() object you should always use "JPEG" as the requested output format. If you work with actual files then the file extension is used in place of the format info. Hope this explains things. If interested Pillow can be found on github and you can see the source. KevinH |
Thanks for the clarification, KevinH.
|
Hi,
I tried to add another span replacement. If you have a <span style="font-variant:small-caps;"> to replace it with \U\1\E but it doesn't work :P I add a Code:
elif comboBox[i].get() == "Change to UPPER":I search and i found that if you want the Code:
\Uabc\EdefCode:
re.search("abc".upper() + "def", var)Thanks! |
CalibUser is possible to use the code for the hypens fix with other character?
For example... Sometimes you get Code:
"ύ" instead of "έ"Thanks |
| All times are GMT -4. The time now is 08:29 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.