redmine_apijs 6.9.4 → 6.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/image.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/python3
2
2
  # -*- coding: utf8 -*-
3
3
  # Created J/26/12/2013
4
- # Updated M/23/05/2023
4
+ # Updated J/05/10/2023
5
5
  #
6
6
  # Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
7
7
  # Copyright 2020-2023 | Fabrice Creuzot <fabrice~cellublue~com>
@@ -26,11 +26,11 @@ try:
26
26
  quality = int(sys.argv[5]) if len(sys.argv) >= 6 else 0
27
27
  fixed = len(sys.argv) >= 7 and sys.argv[6] == 'fixed'
28
28
  except:
29
- print("Usage: image.py source_file destination_file width_px height_px [quality=0:auto..100 or 0:auto..9 for png] [fixed]")
30
- print("source: all supported format by python-pil (including animated gif/png/webp),")
31
- print(" or all supported format by ffmpegthumbnailer,")
32
- print(" or svg")
33
- print("destination: jpg,gif,png,webp or svg")
29
+ print('Usage: image.py source_file destination_file width_px height_px [quality=0:auto..100 or 0:auto..9 for png] [fixed]')
30
+ print('source: all supported format by python-pil (including animated gif/png/webp),')
31
+ print(' or all supported format by ffmpegthumbnailer,')
32
+ print(' or svg')
33
+ print('destination: jpg,gif,png,webp or svg')
34
34
  exit(-1)
35
35
 
36
36
  # https://stackoverflow.com/a/273227/2980105
@@ -254,14 +254,14 @@ def saveJpg(dest, fileout, quality):
254
254
  #try:
255
255
  # import pyguetzli
256
256
  # filefinal = pyguetzli.process_pil_image(dest.convert('RGB'), quality)
257
- # output = open(fileout, "wb")
257
+ # output = open(fileout, 'wb')
258
258
  # output.write(filefinal)
259
259
  #except ImportError:
260
260
  dest.convert('RGB').save(fileout, 'JPEG', optimize=True, subsampling=0, quality=quality)
261
261
 
262
262
 
263
263
  # python-scour
264
- if ".svg" in fileout:
264
+ if '.svg' in fileout:
265
265
  from scour.scour import sanitizeOptions, start
266
266
  options = sanitizeOptions()
267
267
  options.strip_xml_prolog = True # --strip-xml-prolog
@@ -274,7 +274,7 @@ if ".svg" in fileout:
274
274
  else:
275
275
  from PIL import Image, ImageSequence
276
276
 
277
- if ".ogv" in filein or ".webm" in filein or ".mp4" in filein:
277
+ if '.ogv' in filein or '.webm' in filein or '.mp4' in filein:
278
278
  # from video
279
279
  source = videoToImage(filein, fileout, size)
280
280
  imgext = 'VIDEO'
@@ -285,19 +285,27 @@ else:
285
285
  size = calcSize(source, size)
286
286
 
287
287
  # filein = fileout = /tmp/phpA5kbkc when replace tmp image with re-sampled copy to exclude images with malicious data
288
- if imgext == 'GIF' and (same or ".gif" in fileout):
288
+ # @todo for animated GIF to animated GIF (or PNG), sadly, result file is not optimized, the idea is to reprocess the file to not replace each frames by another one
289
+ # for my test image, https://github.com/kohler/gifsicle, don't do it, but https://kraken.io/web-interface do it
290
+ if imgext == 'GIF' and (same or '.gif' in fileout):
289
291
  dest = resizeAnimatedGif(source, size, fixed)
290
292
  saveGif(dest, fileout, quality)
291
- elif imgext == 'GIF' and (same or ".webp" in fileout):
293
+ elif imgext == 'GIF' and ( '.png' in fileout): # @todo
294
+ dest = resizeAnimatedGif(source, size, fixed)
295
+ savePng(dest, fileout, quality)
296
+ elif imgext == 'GIF' and ( '.webp' in fileout):
292
297
  dest = resizeAnimatedGif(source, size, fixed)
293
298
  saveWebp(dest, fileout, quality)
294
- elif imgext == 'PNG' and (same or ".png" in fileout):
299
+ elif imgext == 'PNG' and (same or '.png' in fileout):
295
300
  dest = resizeAnimatedPng(source, size, fixed)
296
301
  savePng(dest, fileout, quality)
297
- elif imgext == 'PNG' and (same or ".webp" in fileout):
302
+ elif imgext == 'PNG' and ( '.gif' in fileout):
303
+ dest = resizeAnimatedPng(source, size, fixed)
304
+ saveGif(dest, fileout, quality)
305
+ elif imgext == 'PNG' and ( '.webp' in fileout):
298
306
  dest = resizeAnimatedPng(source, size, fixed)
299
307
  saveWebp(dest, fileout, quality)
300
- elif imgext == 'WEBP' and (same or ".webp" in fileout):
308
+ elif imgext == 'WEBP' and (same or '.webp' in fileout):
301
309
  dest = resizeAnimatedWebp(source, size, fixed)
302
310
  saveWebp(dest, fileout, quality)
303
311
  else:
@@ -340,11 +348,11 @@ else:
340
348
  if hasTransparency(source) is False:
341
349
  dest = dest.convert('RGB')
342
350
 
343
- if ".gif" in fileout or (same and imgext == 'GIF'):
351
+ if '.gif' in fileout or (same and imgext == 'GIF'):
344
352
  saveGif(dest, fileout, quality)
345
- elif ".png" in fileout or (same and imgext == 'PNG'):
353
+ elif '.png' in fileout or (same and imgext == 'PNG'):
346
354
  savePng(dest, fileout, quality)
347
- elif ".webp" in fileout or (same and imgext == 'WEBP'):
355
+ elif '.webp' in fileout or (same and imgext == 'WEBP'):
348
356
  saveWebp(dest, fileout, quality)
349
357
  else:
350
358
  saveJpg(dest, fileout, quality)
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'redmine_apijs'
4
- s.version = '6.9.4'
4
+ s.version = '6.9.5'
5
5
  s.summary = 'Redmine Apijs plugin'
6
6
  s.description = 'Integrate the apijs JavaScript library into Redmine. Provides a gallery for image and video attachments. Gem for Redmine 3.0+ (tested with 3.0..5.0), for Redmine 4.1+ read https://redmine.org/issues/31110#note-8'
7
7
  s.homepage = 'https://github.com/luigifab/redmine-apijs'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_apijs
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.9.4
4
+ version: 6.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabrice Creuzot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Integrate the apijs JavaScript library into Redmine. Provides a gallery
14
14
  for image and video attachments. Gem for Redmine 3.0+ (tested with 3.0..5.0), for