local-fastimage_resize 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 50c371403135f3114a00aa4bc6c5f4b6dfb9b33c
4
- data.tar.gz: a94a1d8ac982dfed7ac8f2c923f90361e105472c
2
+ SHA256:
3
+ metadata.gz: 7a7a5852a9c12e9eb1da31bc031d8b39556025aa14a3df7cd21e63c23fe022c0
4
+ data.tar.gz: d5cb5920f6434683f56bb828cfb6b4dcd1742ae28e6184fe7b9e559cd2a61947
5
5
  SHA512:
6
- metadata.gz: 8f6caeb867b93b16d3ed126ca508cbc2ba020108f063ee8ce6dee6017e4b1dcc0a3f2e9224bd7f11e3c4647e0c1aa89ed22eb9d1c280e25ebe78a45ecb521331
7
- data.tar.gz: 884d0de764ada380b77cd97841fc803eab00e52f9b3ad997f31cc20cc92fdf30737609bb8b94ed7adad16992ccf0091828e1b8f9730381cbb17bac9043c1f7d8
6
+ metadata.gz: 6d60ea4c09f3901652548da85b723ea6b48959ec60a0633823e1b2a7a05a4318da716b36839d39bd2d9a7521eb3296e1eee459e9849df68c5359844d1c764d1d
7
+ data.tar.gz: 8f145aeae41f9e0cfb9aec8d56bc7b5a7b9beddec9d5d31496268434f247bd99dcd3a9c74c5e7a62b36d035dc3a78897faa232a90585fc886fa841d453a595fe
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.9
4
- - 2.2.5
5
- - 2.3.1
3
+ - 2.2.10
4
+ - 2.3.7
5
+ - 2.4.4
6
+ - 2.5.1
6
7
 
7
8
  before_install:
8
9
  - gem install bundler
@@ -1,3 +1,16 @@
1
+ # 3.3.0 - 2018-04-24
2
+
3
+ Support for Exif orientation.
4
+
5
+ Images are rotated and flipped automatically based on Exif data, so that the
6
+ generated thumbnails follow the specified orientation.
7
+
8
+ Support for easy non-scaling operation
9
+
10
+ By providing `0` for both width and height, the image will not be scaled but
11
+ merely re-encoded to the target location. This may be useful in combination with
12
+ the above mentioned automatic Exif orientation handling,
13
+
1
14
  # 3.2.0 - 2017-09-08
2
15
 
3
16
  Check for some error cases in gd calls which might have resulted in null-pointer exceptions and subsequent segfaults.
data/README.md CHANGED
@@ -7,6 +7,7 @@ It features the following differences:
7
7
 
8
8
  * Removal of all remote image handling code
9
9
  * Replacing RubyInline with native extension
10
+ * Support for Exif orientation
10
11
  * Minor changes to code organization
11
12
 
12
13
  [![Build
@@ -29,15 +29,15 @@ h2. Examples
29
29
  <code>
30
30
  require 'fastimage_resize'
31
31
 
32
- FastImage.resize("example.gif", 100, 20, :outfile=>"my.gif")
32
+ FastImage.resize("example.gif", 100, 20, outfile: "my.gif")
33
33
  => nil
34
34
 
35
35
  outfile = FastImage.resize("nonexistentfile.png", 50, 50)
36
- =>FastImage::ImageFetchFailure: FastImage::ImageFetchFailure
36
+ => FastImage::ImageFetchFailure: FastImage::ImageFetchFailure
37
37
 
38
38
  outfile = FastImage.resize("afile.png", 50, 150)
39
39
  => #<File:/var/folders/vm/vd65y2597xl_by6c73_m9j1h0000gn/T/FastImage20111003-7638-x3l8r7-0.png>
40
-
40
+
41
41
  File.open("afile.png", "r") {|f| FastImage.resize(f, 100, 100)}
42
42
  => #<File:/var/folders/vm/vd65y2597xl_by6c73_m9j1h0000gn/T/FastImage20111003-7638-y1ofh-0.png>
43
43
  </code>
data/Rakefile CHANGED
@@ -14,4 +14,4 @@ Rake::ExtensionTask.new "fastimage_native_resize"
14
14
 
15
15
  Rake::Task[:test].prerequisites << :compile
16
16
 
17
- task :default => :test
17
+ task default: :test
@@ -1,19 +1,21 @@
1
1
  #include <ruby.h>
2
2
  #include <gd.h>
3
3
 
4
- // static void d(VALUE v) {
5
- // ID sym_puts = rb_intern("puts");
6
- // ID sym_inspect = rb_intern("inspect");
7
- // rb_funcall(rb_mKernel, sym_puts, 1, rb_funcall(v, sym_inspect, 0));
8
- // }
9
-
10
- static VALUE fastimage_native_resize(VALUE self, VALUE rb_in, VALUE rb_out, VALUE rb_w, VALUE rb_h, VALUE rb_image_type, VALUE rb_jpeg_quality) {
4
+ static VALUE fastimage_native_resize(
5
+ VALUE self,
6
+ VALUE rb_in, VALUE rb_out,
7
+ VALUE rb_w, VALUE rb_h,
8
+ VALUE rb_image_type,
9
+ VALUE rb_jpeg_quality,
10
+ VALUE rb_orientation
11
+ ) {
11
12
  char *filename_in = StringValuePtr(rb_in);
12
13
  char *filename_out = StringValuePtr(rb_out);
13
14
  int w = NUM2INT(rb_w);
14
15
  int h = NUM2INT(rb_h);
15
16
  int image_type = NUM2INT(rb_image_type);
16
17
  int jpeg_quality = NUM2INT(rb_jpeg_quality);
18
+ int orientation = NUM2INT(rb_orientation);
17
19
 
18
20
 
19
21
  gdImagePtr im_in, im_out;
@@ -53,16 +55,48 @@ static VALUE fastimage_native_resize(VALUE self, VALUE rb_in, VALUE rb_out, VALU
53
55
  return Qnil;
54
56
  }
55
57
 
58
+
59
+
60
+ /* Handle orientation */
61
+ if (orientation == 5 || orientation == 6) {
62
+ im_in = gdImageRotateInterpolated(im_in, 270.0, 0);
63
+ }
64
+ if (orientation == 7 || orientation == 8) {
65
+ im_in = gdImageRotateInterpolated(im_in, 90.0, 0);
66
+ }
67
+ if (!im_in) {
68
+ fclose(in);
69
+ return Qnil;
70
+ }
71
+
72
+ if (orientation == 2 || orientation == 5 || orientation == 7) {
73
+ gdImageFlipHorizontal(im_in);
74
+ }
75
+ if (orientation == 3) {
76
+ gdImageFlipBoth(im_in);
77
+ }
78
+ if (orientation == 4) {
79
+ gdImageFlipVertical(im_in);
80
+ }
81
+
82
+
83
+
84
+ /* Compute target size */
56
85
  if (w == 0 || h == 0) {
57
86
  int originalWidth = gdImageSX(im_in);
58
87
  int originalHeight = gdImageSY(im_in);
59
- if (w == 0) {
88
+ if (h != 0) {
60
89
  w = (int)(h * originalWidth / originalHeight);
61
- } else {
90
+ } else if (w != 0) {
62
91
  h = (int)(w * originalHeight / originalWidth);
92
+ } else {
93
+ w = originalWidth;
94
+ h = originalHeight;
63
95
  }
64
96
  }
65
97
 
98
+
99
+
66
100
  im_out = gdImageCreateTrueColor(w, h); /* must be truecolor */
67
101
  if (im_out) {
68
102
  if (image_type == 1) {
@@ -107,5 +141,5 @@ void Init_fastimage_native_resize(void) {
107
141
 
108
142
  cFastImageResize = rb_const_get(rb_cObject, rb_intern("FastImage"));
109
143
 
110
- rb_define_singleton_method(cFastImageResize, "native_resize", fastimage_native_resize, 6);
144
+ rb_define_singleton_method(cFastImageResize, "native_resize", fastimage_native_resize, 7);
111
145
  }
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+ #
1
3
  # FastImage Resize is an extremely light solution for resizing images in ruby by using libgd
2
4
  #
3
5
  # === Examples
4
6
  #
5
7
  # require 'fastimage_resize'
6
8
  #
7
- # FastImage.resize("image.gif", 100, 20, :outfile=>"thumbnail.gif")
9
+ # FastImage.resize("image.gif", 100, 20, outfile: "thumbnail.gif")
8
10
  # => 1
9
11
  #
10
12
  # === Requirements
@@ -47,7 +49,7 @@ module FastImage::Resize
47
49
  #
48
50
  # require 'fastimage_resize'
49
51
  #
50
- # FastImage.resize("http://stephensykes.com/images/ss.com_x.gif", 100, 20, :outfile=>"my.gif")
52
+ # FastImage.resize("http://stephensykes.com/images/ss.com_x.gif", 100, 20, outfile: "my.gif")
51
53
  #
52
54
  # === Supported options
53
55
  # [:jpeg_quality]
@@ -56,7 +58,7 @@ module FastImage::Resize
56
58
  # Name of a file to store the output in, in this case a temp file is not used
57
59
  #
58
60
  def resize(source, width, height, options={})
59
- new(source, :raise_on_failure => true).resize(width, height, options)
61
+ new(source, raise_on_failure: true).resize(width, height, options)
60
62
  end
61
63
  end
62
64
 
@@ -75,7 +77,7 @@ module FastImage::Resize
75
77
  temp_file = nil
76
78
  end
77
79
 
78
- FastImage.native_resize(path, file_out.to_s, width.to_i, height.to_i, type_index, jpeg_quality.to_i)
80
+ FastImage.native_resize(path, file_out.to_s, width.to_i, height.to_i, type_index, jpeg_quality.to_i, orientation)
79
81
 
80
82
  raise FastImage::ImageFetchFailure, 'Image could be created' unless File.exist?(file_out.to_s)
81
83
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FastImage
2
4
  module Resize
3
- VERSION = "3.2.0"
5
+ VERSION = "3.3.0"
4
6
  end
5
7
  end
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency "local-fastimage", "~> 3.0"
26
26
 
27
- s.add_development_dependency "bundler", "~> 1.12"
28
- s.add_development_dependency "rake", "~> 10.0"
29
- s.add_development_dependency "minitest", "~> 5.0"
30
- s.add_development_dependency "rake-compiler", "~> 0.9.9"
27
+ s.add_development_dependency "bundler"
28
+ s.add_development_dependency "rake"
29
+ s.add_development_dependency "minitest"
30
+ s.add_development_dependency "rake-compiler"
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local-fastimage_resize
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-08 00:00:00.000000000 Z
12
+ date: 2018-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: local-fastimage
@@ -29,58 +29,58 @@ dependencies:
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '1.12'
34
+ version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '1.12'
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '10.0'
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '10.0'
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '5.0'
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '5.0'
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake-compiler
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 0.9.9
76
+ version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 0.9.9
83
+ version: '0'
84
84
  description: Local FastImage Resize is an extremely light solution for resizing images
85
85
  in ruby by using libgd.
86
86
  email:
@@ -97,7 +97,6 @@ files:
97
97
  - CHANGELOG.md
98
98
  - Gemfile
99
99
  - MIT_LICENCE
100
- - README
101
100
  - README.md
102
101
  - README.textile
103
102
  - Rakefile
@@ -128,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - libgd, see www.libgd.org
130
129
  rubyforge_project:
131
- rubygems_version: 2.6.13
130
+ rubygems_version: 2.7.6
132
131
  signing_key:
133
132
  specification_version: 4
134
133
  summary: Local FastImage Resize - Image resizing fast and simple
data/README DELETED
@@ -1,27 +0,0 @@
1
- FastImage Resize is an extremely light solution for resizing images in ruby by using libgd
2
-
3
- === Examples
4
-
5
- require 'fastimage_resize'
6
-
7
- FastImage.resize("http://stephensykes.com/images/ss.com_x.gif", "my.gif", 100, 20)
8
- => 1
9
-
10
- === Requirements
11
-
12
- RubyInline
13
-
14
- gem install RubyInline
15
-
16
- FastImage
17
-
18
- gem install fastimage
19
-
20
- Libgd
21
-
22
- See http://www.libgd.org/
23
- Libgd is commonly available on most unix platforms, including OSX.
24
-
25
- === References
26
-
27
- * http://blog.new-bamboo.co.uk/2007/12/3/super-f-simple-resizing