View Single Post
Old 12-28-2011, 02:28 AM   #1
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,615
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
A homebrewed program for viewing image archives (cbz, cbr,...)

pbimageviewer is a program for viewing collections of images. The images can be collected within a directory, or within archives such as CBZ/ZIP, CBR/RAR and TAR files. Images can be zoomed/unzoomed, and navigation over the images can be done with the buttons and/or the stylus. For people without touchscreens, full navigation is available via the buttons. For cartoons/manga, the program can automatically detect separated panels, fit each panel to the screen if desired, and jump between panels using the buttons. As a non-touchscreen owner myself, I was motivated to make the experience easier for those of us relying on buttons.

CBZ and CBR files are unpacked within the program, and no external programs are required.

To use the program, download the correct version for your device from the links at the bottom of this post. The 3XX version is for the older 301, 302 and 360 models. The Pro-360+ version is for all the rest of the PocketBook models that were released more recently (including the Touch).

To use the program to view archives, you just need to unzip and copy the provided pbimageviewer-***.app file to system/bin/pbimageviewer.app on the device, and then edit the system/config/extensions.cfg file to make the system recognize the archive files as books. After that, you should be able to open .cbz or .cbr files in the library app.

The following is what I added to my extensions.cfg file (note that the name of the app on each line should match with the name of the file it was copied to in the system/bin directory):

Code:
zip:@ZIP_file:1:pbimageviewer.app:ICON_JPG
cbz:@ZIP_file:1:pbimageviewer.app:ICON_JPG
rar:@RAR_file:1:pbimageviewer.app:ICON_JPG
cbr:@RAR_file:1:pbimageviewer.app:ICON_JPG
tar:@TAR_file:1:pbimageviewer.app:ICON_JPG
tar.gz:@TAR_file:1:pbimageviewer.app:ICON_JPG
tgz:@TAR_file:1:pbimageviewer.app:ICON_JPG
tar.bz2:@TAR_file:1:pbimageviewer.app:ICON_JPG
tbz2:@TAR_file:1:pbimageviewer.app:ICON_JPG
N.B. I can't seem to open .zip files because it looks like the Library application won't allow it. The simple fix is to change the file extension from .zip to .cbz on the archive files.

You can also copy the pbimageviewer.app file to applications/ and then use it via the Applications tab to look at already existing image folders.

------

Here is part of the announcement for the first release, for historical purposes:

I had been grumbling about needing to convert manga and comics to PDF or EPUB for reading on my 902, and finally decided to do something about it. I found a nice image viewing program written by Michail Polubisok (aka Dirondin) that could be used to view images in a directory. I added code to automatically unpack archives of images (in ZIP, RAR and TAR formats), and then since these archives were like books, I added many Inkview book features to the software as well (like Table of Contents and Page Selector for navigation, changing orientation, saving state and configuration options,...). The unpacking of archives is rather crude (it relies on the external programs unzip, unrar and tar), but for a first version, I find the program to be very useable even at this stage.

I've contacted Michail to help improve it, however he is very busy with schoolwork and a job right now, so I've decided to release the program as is and get some feedback on its useability before working on improvements to the archive handling code.

There is currently no support for a touchscreen, mostly because I don't have one. However, I'm sure the stylus would be very handy for panning zoomed-in images, and I expect it'll be added later if someone with a touch device wants to help with that. I've also written the menus to be internationalizable, so if anyone wants to help provide translations for other languages, they would be more than welcome.

I've put together a zip file with the necessary programs for both the newer Pro (and 360+) devices and for the older 30X/360 devices, as well. The latter are completely untested by me and may not even work, but I live in hope. I'll provide a link to the source code and unrar/unzip packages when I have that ready sometime soon.

------

Edit: Sorry, the first version of the Pro zip file had a version of unrar that wouldn't work on the devices. I re-uploaded the zip with a working version.

Edit 2: Uploaded new versions with some bug fixes.

Edit 3: Added custom zoom level feature requested by @dtanis.

Edit 4: Added configuration item to force unpacking of archives into /tmp rather than the directory that the archive file is in. This is useful if unpacking into the FAT directories fails for some reason (like non-ASCII characters in image filenames).

Edit 5: Added popup dictionary. Also switched from using the external unzip and unrar programs to using libzip and libunrar. So, unrar and unzip aren't provided in the zip file anymore. The program starts up and shuts down much faster now since each image is unpacked as needed (rather than all the images at once in the beginning), it takes up much less file space when running, and all images are temporarily unpacked to /tmp so that odd characters in filenames shouldn't be a problem anymore.

Edit 6: Added support for BMP and GIF images. Thanks to a lot of testing and excellent suggestions by @dtanis, I've been able to add support for using the stylus to control the program. You can pop up the main menu by tapping, pan the image and change pages by swiping with the stylus, and set the custom zoom by dragging across the part of the image you want to zoom in on. Horizontal panning was disabled in custom zoom mode so that swiping and left/right button pushes could be used to change pages then. This is pretty much everything I wanted to add to the program, so I don't expect many more features to go in after this. Still, suggestions and bug reports are always welcome. (Sorry, original uploads had a bug when decoding some GIFs, so a fixed version has been uploaded)

Edit 7: Added a menu item for rotating the screen if the global setting isn't set to automatic (for @fsvum). If it is set to automatic, then the program just behaves as before. So, there is no need to re-download and install if you use automatic orientation all the time.

Edit 8: Added support for (single image) TIFF files. Fixed a memory leak while decompressing RAR files.

Edit 9: Added menu and configuration options for enabling/disabling the status bar at the bottom of the display (for @vomov).

Edit 10: Added icons to the global configuration menu to make the text readable. Also added cartoon panel detection and navigation, so that those without a touchscreen could more easily read cartoons and manga.

Edit 11: Fixed handling of RGB data from PNG images when detecting cartoon panels.

Edit 12: Fixed rotation menu items, and the saving of state when the program was backgrounded. Also, added the option of automatically enlarging each cartoon panel to fit within the display. Thanks to PascalV for the bug reports and the suggestion.

Edit 13: Updated the beginning of this post to better reflect how the program now works (instead of how it worked on the first release).

Edit 14: Fixed the broken touch functionality, configuration page, and added zoom by pinching, all for the Touch 622. Thanks to luigibrosse, DmitryZ and seiichiro018 for helping me with that. Changed zooming to try to keep the same point at the center of the image.

Edit 15: Added support for zip and rar archives encrypted by a simple password. Added French, Portuguese and German translations (thanks to PascalV and seiichiro018). The step size percentage can now be configured to give 611 users a little more control (thanks to Klapo). The current image can now be saved to a configurable directory via the main menu.

Edit 16: Added the ability to automatically start the next archive in the directory, and also to automatically restart archives at the beginning if they were exited on the last page previously. Both features need to be enabled in the configuration page, as they are off by default. @dtanis has also supplied a full Dutch translation, and a partial Japanese translation (to be finished later), and PascalV and seiichiro018 have updated the French, Portuguese and German translations for the new features.

Edit 17: The last update had a broken configuration on the Touch. A fixed version was uploaded. The version for the older 3XX devices wasn't changed.

Edit 18: Added automatic startup after booting. Improved sorting of filenames in archives. Check magic number of RAR and ZIP files in case they are named incorrectly. Instantly apply Auto Panel Mode to current page, plus show icons in the bottom panel to indicate when the mode is on (as well as when auto resizing of panels is on). Added Brightness/Contrast/Gamma controls. Changed Next/Prev buttons on the Touch to step between panels in that mode, or just step the pages up and down otherwise. Added global configuration item for setting the screen orientation at startup (unless Automatic Orientation is enabled on the device). Added translations from dtanis, PascalV and seiichiro018.

Edit 19: Fixed a bug where the app crashed when launched from the Applications tab. Thanks to Dungeone for pointing it out.

Edit 20: Added the Touch Lux to the list of devices that use the new configuration structure. Thanks to seiichiro0185 for the patch.

Edit 21: No new features, but made the app work better on the newer touch devices. Colour images should be visible on the Colour Lux. Tailored the Help page to only show info on buttons that the current device has. Debug logging can now be enabled/disabled in the configuration.

Edit 22: Added automatic checking of file magic numbers for opened directories and CBZ files. Checking inside CBR files is slow, so it has been added as a configuration option. Added the ability to define the device capabilities via a configuration file, so new devices can be supported without requiring the source code to be updated. This should fix the crashes seen on the latest devices. People with 614, 624 and 626 model devices should download the device_cfg.zip file and unpack it into their internal memory so that the new XXX.cfg files end up inside the system/share/pbiv/ directory. The zip file will be updated as new models emerge in the future. There is a brand new Hungarian translation produced by @gyeben, so many thanks to him for that!

Edit 23: Fixed a bug for the Colour Lux where new archives always started out as black and white rather than colour. People with other models don't need to update if they did so recently.

Edit 24: Fixed the problem that munenori had with the missing rotation menu. This only applies to new devices without a g-sensor, and maybe only the 611 with new firmware.

The source code and binaries are also available at: http://www3.telus.net/rkomar/pbimageviewer/. A debug version of pbimageviewer.app for the latest devices is also available at the website, and can be used with gdb and pbterm to debug crashes.
Attached Files
File Type: zip pbimageviewer.app-3XX.zip (168.0 KB, 95 views)
File Type: zip device_cfg.zip (3.2 KB, 101 views)
File Type: zip pbimageviewer.app-Pro-360+.zip (142.5 KB, 70 views)

Last edited by rkomar; 06-12-2014 at 11:10 PM.
rkomar is offline   Reply With Quote