Merge pull request #14 from Leeingnyo/change-page-sort

Sort page names alphanumerically
This commit is contained in:
Alex Ling
2020-03-12 13:37:59 -04:00
committed by GitHub
3 changed files with 53 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ require "zip"
require "mime"
require "json"
require "uri"
require "./util"
struct Image
property data : Bytes
@@ -44,7 +45,7 @@ class Entry
["image/jpeg", "image/png"].includes? \
MIME.from_filename? e.filename
}
.sort { |a, b| a.filename <=> b.filename }
.sort { |a, b| compare_alphanumerically(split_by_alphanumeric(a.filename), split_by_alphanumeric(b.filename)) }
.[page_num - 1]
page.open do |io|
slice = Bytes.new page.uncompressed_size