MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   ePUB Optimizer (https://www.mobileread.com/forums/showthread.php?t=252010)

eschwartz 12-02-2014 08:13 PM

If you need source packages, try checking http://archlinux.org/packages which will provide the Upstream Urls instead of repackaging the sources.

KevinH 12-02-2014 10:38 PM

Hi eschwartz,

Quote:

Originally Posted by eschwartz (Post 2992177)
If you need source packages, try checking http://archlinux.org/packages which will provide the Upstream Urls instead of repackaging the sources.

Thanks for the link. Unfortunately, I found out that pngout.exe is proprietary code that no source has been released for. Someone else has built a binary of it for older Macs running OS X 10.4, but I gave up running binaries I find on the web from unknown/untrusted sources long ago. I am surprised it runs on Linux.

Thanks,

Kevin

eschwartz 12-02-2014 11:55 PM

Oh, that seems to be priceless. :rolleyes:
I really love closed-source linux programs, too... I am sure it runs, it just won't be packaged by anybody.

Is pngout actually being used? It probably isn't necessary, how many different png optimizers does one program need?
But assuming we want to squeeze every possible byte out, a noteworthy goal, perhaps it is a better idea to use zopflipng which is part of google's open-source zopfli compression engine (alternative to deflate, it takes 2-3 times longer in order to find the smallest compression path). It even claims to be marginally better than pngout, by a whole 0.5%
https://code.google.com/p/zopfli/sou...ADME.zopflipng

Toxaris 12-03-2014 03:09 AM

You can ignore PNGOUT. It is an old leftover I apparently forgot to delete. The reason I kicked it out, is that there is no Linux/OSX version and it is closed source (no way to rebuild if the need arises).
The program is checking what the OS is to determine how to call the image optimizing programs. If I recall correctly (will look it up later today), on Windows systems it will use the executables in the directory and for Linux (and also OSX) it should use the ones in the path. Based on your error report, it seems that it does not starts fine, it tries to open 'open'. I will get back to you.

Toxaris 12-03-2014 03:59 AM

As it is now, I am detecting if it is running on Windows or other. If it is running on other, it will not give a pathname, but just execute the command. For jpegtran the command would be like:

jpegtran -optimize -progressive -copy none -outfile <filename> <filename>

Could you check if that is working on OSX?

KevinH 12-03-2014 10:29 AM

Hi Toxaris,

Will check that and get back to you. One approch to making a cross-platform plugin that has binaries might be to create your own winbin\, osxbin/, linuxbin/ directories in the plugin folder and store the small required binaries in those and then invoke them with the correct full path depending on what sys you are running on. The platform can be easily detected by python and passed in if need be.

That way, no one has to build those binaries on OSX as there are no simple packages for Mac users.

I have tried setting the path env var to point to the binaries but I am not sure since you use subprocess to invoke it if those environment vars are properly picked up in the child process or not.

KevinH

JSWolf 12-03-2014 10:35 AM

Quote:

Originally Posted by Toxaris (Post 2992361)
As it is now, I am detecting if it is running on Windows or other. If it is running on other, it will not give a pathname, but just execute the command. For jpegtran the command would be like:

jpegtran -optimize -progressive -copy none -outfile <filename> <filename>

Could you check if that is working on OSX?

You can actually optimize the images even better as long as you first figure out if they are grayscale or RGB and apply the appropriate profile.

For RGB
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_rgb.txt <filename> <filename>

For grayscale
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_bw.txt <filename> <filename>

For PNG, there is an open source optimizer called OptiPNG that you could use. http://optipng.sourceforge.net/
There is also another free PNG optimizer called PNG Optimizer. http://sourceforge.net/projects/pngoptimizer/

KevinH 12-03-2014 11:10 AM

Hi,

I think your trying to write over the same file you read from is the issue on Mac OS X.

Code:

kbhend$ ./jpegtran -optimize -progressive -copy none -outfile ../junk.jpg ../PluginRunner.jpg
It successfully creates junk.jpg with no errors.

But if I try to overwrite the same file in-place ...

Code:

kbhend$ ./jpegtran -optimize -progressive -copy none -outfile ../test.jpg ../test.jpg

Empty input file

I get back the same "Empty input file" error I saw previously.
So at least on Mac OS X you can't overwrite in place.

Hope this helps,

KevinH


Quote:

Originally Posted by Toxaris (Post 2992361)
As it is now, I am detecting if it is running on Windows or other. If it is running on other, it will not give a pathname, but just execute the command. For jpegtran the command would be like:

jpegtran -optimize -progressive -copy none -outfile <filename> <filename>

Could you check if that is working on OSX?


eschwartz 12-03-2014 11:29 AM

Quote:

Originally Posted by JSWolf (Post 2992653)
For PNG, there is an open source optimizer called OptiPNG that you could use. http://optipng.sourceforge.net/
There is also another free PNG optimizer called PNG Optimizer. http://sourceforge.net/projects/pngoptimizer/

Tbis plugin already uses optipng.

Toxaris 12-03-2014 12:46 PM

Quote:

Originally Posted by KevinH (Post 2992651)
One approch to making a cross-platform plugin that has binaries might be to create your own winbin\, osxbin/, linuxbin/ directories in the plugin folder and store the small required binaries in those and then invoke them with the correct full path depending on what sys you are running on. The platform can be easily detected by python and passed in if need be.

That way, no one has to build those binaries on OSX as there are no simple packages for Mac users.

I have tried setting the path env var to point to the binaries but I am not sure since you use subprocess to invoke it if those environment vars are properly picked up in the child process or not.

KevinH

You have a point there. The only catch would be that additional libraries would be needed, but I should be able to test that.

Toxaris 12-03-2014 12:49 PM

Quote:

Originally Posted by KevinH (Post 2992679)
Hi,

I think your trying to write over the same file you read from is the issue on Mac OS X.

Code:

kbhend$ ./jpegtran -optimize -progressive -copy none -outfile ../junk.jpg ../PluginRunner.jpg
It successfully creates junk.jpg with no errors.

But if I try to overwrite the same file in-place ...

Code:

kbhend$ ./jpegtran -optimize -progressive -copy none -outfile ../test.jpg ../test.jpg

Empty input file

I get back the same "Empty input file" error I saw previously.
So at least on Mac OS X you can't overwrite in place.

Hope this helps,

KevinH

That helps a lot. Together with the new algorithm I have written to detect the OS, it would work. I think I will include the OSX executables just like the Windows executables. On Linux they can be retrieved easily enough.

KevinH 12-03-2014 01:20 PM

Hi Toxaris,

Quote:

Originally Posted by Toxaris (Post 2992762)
That helps a lot. Together with the new algorithm I have written to detect the OS, it would work. I think I will include the OSX executables just like the Windows executables. On Linux they can be retrieved easily enough.

Glad to hear it. Do you want me to zip up the Mac OS X binaries and send them to you? Or do you want me to wait until we get something working on Mac OS X first?

Thanks,

Kevin

Toxaris 12-03-2014 04:07 PM

Quote:

Originally Posted by KevinH (Post 2992789)
Hi Toxaris,



Glad to hear it. Do you want me to zip up the Mac OS X binaries and send them to you? Or do you want me to wait until we get something working on Mac OS X first?

Thanks,

Kevin

Let's make it work first... I will sent you a message later with a test version...

JSWolf 12-03-2014 08:43 PM

Toxaris, do you think you can implement the following so we get even better jpeg optimization?

For RGB
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_rgb.txt <filename> <filename>

For grayscale
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_bw.txt <filename> <filename>

Toxaris 12-04-2014 09:54 AM

Quote:

Originally Posted by JSWolf (Post 2993169)
Toxaris, do you think you can implement the following so we get even better jpeg optimization?

For RGB
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_rgb.txt <filename> <filename>

For grayscale
jpegtran.exe" -optimize -progressive -copy none -scans jpeg_scan_bw.txt <filename> <filename>

No, not until I can find a good way to determine if a picture is grayscale or color.


All times are GMT -4. The time now is 08:27 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.