inkcite 1.15.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/inkcite.gemspec +0 -3
  4. data/lib/inkcite.rb +0 -1
  5. data/lib/inkcite/cli/base.rb +12 -8
  6. data/lib/inkcite/cli/preview.rb +0 -10
  7. data/lib/inkcite/cli/server.rb +9 -1
  8. data/lib/inkcite/email.rb +5 -10
  9. data/lib/inkcite/facade/animation.rb +4 -1
  10. data/lib/inkcite/image_minifier.rb +96 -0
  11. data/lib/inkcite/mailer.rb +2 -2
  12. data/lib/inkcite/minifier.rb +1 -1
  13. data/lib/inkcite/renderer.rb +10 -0
  14. data/lib/inkcite/renderer/base.rb +47 -2
  15. data/lib/inkcite/renderer/button.rb +15 -5
  16. data/lib/inkcite/renderer/container_base.rb +15 -1
  17. data/lib/inkcite/renderer/image.rb +1 -1
  18. data/lib/inkcite/renderer/image_base.rb +8 -0
  19. data/lib/inkcite/renderer/list.rb +104 -0
  20. data/lib/inkcite/renderer/mobile_image.rb +3 -0
  21. data/lib/inkcite/renderer/responsive.rb +2 -0
  22. data/lib/inkcite/renderer/slant.rb +207 -0
  23. data/lib/inkcite/renderer/snow.rb +15 -1
  24. data/lib/inkcite/renderer/special_effect.rb +7 -0
  25. data/lib/inkcite/renderer/sup.rb +18 -4
  26. data/lib/inkcite/renderer/table.rb +9 -1
  27. data/lib/inkcite/renderer/table_base.rb +20 -2
  28. data/lib/inkcite/renderer/td.rb +7 -2
  29. data/lib/inkcite/renderer/video_preview.rb +1 -1
  30. data/lib/inkcite/uploader.rb +40 -27
  31. data/lib/inkcite/version.rb +1 -1
  32. data/lib/inkcite/view.rb +133 -13
  33. data/lib/inkcite/view/context.rb +6 -1
  34. data/lib/inkcite/view/developer_scripts.rb +56 -0
  35. data/test/renderer/background_spec.rb +4 -4
  36. data/test/renderer/button_spec.rb +14 -8
  37. data/test/renderer/div_spec.rb +26 -3
  38. data/test/renderer/image_spec.rb +9 -4
  39. data/test/renderer/list_spec.rb +36 -0
  40. data/test/renderer/mobile_image_spec.rb +5 -0
  41. data/test/renderer/slant_spec.rb +47 -0
  42. data/test/renderer/span_spec.rb +12 -1
  43. data/test/renderer/table_spec.rb +1 -1
  44. data/test/renderer/td_spec.rb +24 -8
  45. data/test/renderer/trademark_spec.rb +6 -6
  46. metadata +11 -50
  47. data/lib/inkcite/image/base.rb +0 -38
  48. data/lib/inkcite/image/guetzli_minifier.rb +0 -62
  49. data/lib/inkcite/image/image_minifier.rb +0 -143
  50. data/lib/inkcite/image/image_optim_minifier.rb +0 -90
  51. data/lib/inkcite/image/mozjpeg_minifier.rb +0 -92
@@ -1,92 +0,0 @@
1
- require 'mozjpeg'
2
-
3
- module Inkcite
4
- module Image
5
- class MozjpegMinifier < ImageMinifier::Base
6
-
7
- def initialize
8
- super('Mozjpeg')
9
- end
10
-
11
- def minify! email, source_img, cache_img
12
-
13
- config = email.config
14
-
15
- cmd = []
16
-
17
- # mozjpeg usage documentation available
18
- # https://github.com/mozilla/mozjpeg/blob/master/usage.txt
19
- cmd << Mozjpeg.cjpeg_path
20
-
21
- chrominance_quality = get_jpg_quality(config, MOZJPEG_CHROMINANCE_QUALITY, DEFAULT_QUALITY)
22
-
23
- # The human eye is more sensitive to spatial changes in brightness than
24
- # spatial changes in color, the chrominance components can be quantized more
25
- # than the luminance components without incurring any visible image quality loss.
26
- luminance_quality = (config[MOZJPEG_LUMINANCE_QUALITY] || DEFAULT_QUALITY).to_i # Recommended default
27
- luminance_quality = MAX_QUALITY if luminance_quality > MAX_QUALITY
28
-
29
- cmd << "-quality #{luminance_quality},#{chrominance_quality}"
30
-
31
- # Perform optimization of entropy encoding parameters.
32
- # -optimize usually makes the JPEG file a little smaller,
33
- # but cjpeg runs somewhat slower and needs much more
34
- # memory. Image quality and speed of decompression are
35
- # unaffected by -optimize.
36
- cmd << '-optimize'
37
-
38
- # Produce progressive JPEGs
39
- cmd << '-progressive'
40
-
41
- subsampling = (config[MOZJPEG_SUBSAMPLING] || DEFAULT_SUBSAMPLING).to_i
42
- cmd << "-sample #{subsampling}x#{subsampling}"
43
-
44
- # Reduces posterization in lower-quality JPEGs
45
- # https://calendar.perfplanet.com/2014/mozjpeg-3-0/
46
- quant_table = (config[MOZJPEG_QUANT_TABLE] || MS_SSIM).to_i
47
- cmd << "-quant-table #{quant_table}"
48
-
49
- # Makes images sharper, at the cost of increased file size
50
- # https://calendar.perfplanet.com/2014/mozjpeg-3-0/
51
- cmd << '-notrellis'
52
-
53
- cmd << %Q(-outfile "#{cache_img}")
54
- cmd << %Q("#{source_img}")
55
-
56
- Util::exec(cmd.join(' '))
57
-
58
- true
59
- end
60
-
61
- private
62
-
63
- # Name of the configuration attributes used to control
64
- # JPEG compression.
65
- MOZJPEG_LUMINANCE_QUALITY = :'mozjpeg-luminance-quality'
66
- MOZJPEG_CHROMINANCE_QUALITY = :'mozjpeg-chrominance-quality'
67
- MOZJPEG_QUANT_TABLE = :'mozjpeg-quant-table'
68
- MOZJPEG_SUBSAMPLING = :'mozjpeg-subsampling'
69
-
70
- # Default compression quality for images unless specified in the
71
- # configuration file under 'mozjpeg-quality'
72
- DEFAULT_QUALITY = 85
73
-
74
- # Default subsampling
75
- DEFAULT_SUBSAMPLING = 1
76
-
77
- # Quality limits
78
- MIN_QUALITY = 0
79
- MAX_QUALITY = 100
80
-
81
- # Quant table constants per the mozjpeg man page
82
- JPEG_ANNEX_K = 0
83
- FLAT = 1
84
- MS_SSIM = 2
85
- IMAGEMAGICK = 3
86
- PSNR_HVS = 4
87
- KLEIN_SILVERSTEIN_CARNEY = 5
88
-
89
- end
90
-
91
- end
92
- end