Skip to content

Commit

Permalink
Request correct image color quality from cantaloupe
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatsson committed Sep 20, 2022
1 parent 7ddff7e commit a1a8426
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scan_explorer_service/manifest_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_image_annotation(self, page: Page):
image: Image = annotation.image(
ident=page.image_path, label=f'p. {page.label}', iiif=True)

image.id = image.id.replace('/default.jpg', '/default.tif')
image.id = image.id.replace(f'/{page.image_color_quality}.jpg', f'/{page.image_color_quality}.tif')

image.format = page.format
image.height = page.height
Expand Down
13 changes: 12 additions & 1 deletion scan_explorer_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,18 @@ def image_path(self):

@property
def thumbnail_url(self):
return f'{self.image_url}/square/480,480/0/default.jpg'
return f'{self.image_url}/square/480,480/0/{self.image_color_quality}.jpg'

@property
def image_color_quality(self):
if self.color_type == PageColor.BW:
return "bitonal"
elif self.color_type == PageColor.Grayscale:
return "gray"
elif self.color_type == PageColor.Color:
return "color"
else:
return "default"

@property
def serialized(self):
Expand Down
2 changes: 1 addition & 1 deletion scan_explorer_service/views/image_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def loop_images(id, page_start, page_end):
size = 'full'
if dpi != 600:
size = str(int(page.width*scaling))+ ","
image_url = page.image_url + "/full/" + size + "/0/default.tif"
image_url = page.image_url + "/full/" + size + f"/0/{page.image_color_quality}.png"
path = urlparse.urlparse(image_url).path
remove = urlparse.urlparse(url_for_proxy('proxy.image_proxy', path='')).path
path = path.replace(remove, '')
Expand Down

0 comments on commit a1a8426

Please sign in to comment.