Tools for working with CBZ comic book archives: reading and extracting their contents, reading and updating their embedded metadata, and converting CBR archives to CBZ.
Install the gem and add to the application's Gemfile by executing:
bundle add cbz_toolsIf bundler is not being used to manage dependencies, install the gem by executing:
gem install cbz_toolsCbzTools::Reader.open("path/to/comic.cbz") do |reader|
reader.image_names # => ["page_001.jpg", "page_002.jpg", ...]
reader.first_image # => "<image bytes>"
reader.comic_info # => {title: "...", page_count: "32", ...}
endCbzTools::Reader.open("path/to/comic.cbz") do |reader|
reader.update_comic_info(title: "New Title", page_count: "32")
endCbzTools::CbrConverter converts CBR archives to CBZ using the unrar
command-line tool (which must be installed on your system).
CbzTools::CbrConverter.convert("path/to/comic.cbr", to: "path/to/comic.cbz")Errors inherit from CbzTools::Error:
CbzTools::CbrConverter::ArchiveError— the destination couldn't be written,overwrite: falseand the destination already exists, orunraris not installed.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/dmfigueroa/cbz_tools.
The gem is available as open source under the terms of the MIT License.