dynamic_image 2.0.15 → 2.0.16

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
2
  SHA256:
3
- metadata.gz: a69d22f3315edf77dae92edc7629a19f997ad75acd07f4767b99c9eea45db784
4
- data.tar.gz: 16cd414f158f77e7b9f94e0c688db074c596234d68199310fca89e1bf7f90f58
3
+ metadata.gz: df3c91615696c4df8f094670ca324626be3a3d33f232b6dd483c22d36d547534
4
+ data.tar.gz: b781ca35542805f1fe34446d60fe23a12d07603c560a1aa9e95f8b519551ea8c
5
5
  SHA512:
6
- metadata.gz: c714fa7783288e08ec5cdbeac3a54df4de2042b528b5c447237d97debf454a97b1150cd74f011b603bd42006faaecbb1f582cfd83df6c7cba1d85a7f344d9a2e
7
- data.tar.gz: 442337018febbed1fd53b2557a47799a218de1b826100e6eb7515c9d41bce963f18e742d01e74cdfc81f0ea84c33eed78eba55b63791dfb7d3ae953431217f33
6
+ metadata.gz: ed8c8fdfe061bf189beb9946faa56c5bb631edd0f4fc1099a71c6fbd07aee2e815299d7acbf0385dfb001186122035d91d6a834bf002383a1d1fb3283ac3a5e7
7
+ data.tar.gz: f80069f885761140e96a98d2aa0c0dc0b47a2b668d9fae06d0afefc49b0ada0c59013c7fe97f8d6f6f7102ab83c747076c0ba2982d1112f58f81ea39b3c028dc
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
  [![Build Status](https://travis-ci.org/elektronaut/dynamic_image.svg?branch=master)](https://travis-ci.org/elektronaut/dynamic_image)
3
3
  [![Code Climate](https://codeclimate.com/github/elektronaut/dynamic_image/badges/gpa.svg)](https://codeclimate.com/github/elektronaut/dynamic_image)
4
4
  [![Code Climate](https://codeclimate.com/github/elektronaut/dynamic_image/badges/coverage.svg)](https://codeclimate.com/github/elektronaut/dynamic_image)
5
- [![Dependency Status](https://gemnasium.com/elektronaut/dynamic_image.svg)](https://gemnasium.com/elektronaut/dynamic_image)
6
5
  [![Inline docs](http://inch-ci.org/github/elektronaut/dynamic_image.svg)](http://inch-ci.org/github/elektronaut/dynamic_image)
7
6
  [![Security](https://hakiri.io/github/elektronaut/dynamic_image/master.svg)](https://hakiri.io/github/elektronaut/dynamic_image/master)
8
7
 
@@ -5,6 +5,18 @@ module DynamicImage
5
5
  # = DynamicImage Model Transformations
6
6
  #
7
7
  module Transformations
8
+ # Resizes the image
9
+ def resize(max_size)
10
+ transform_image do |image|
11
+ new_size = real_size.constrain_both(max_size)
12
+ scale = new_size.x / real_size.x
13
+ image.resize(new_size)
14
+ crop_attributes.each do |attr|
15
+ self[attr] = self[attr] * scale if self[attr]
16
+ end
17
+ end
18
+ end
19
+
8
20
  # Rotates the image
9
21
  def rotate(degrees = 90)
10
22
  degrees = degrees.to_i % 360
@@ -24,6 +36,11 @@ module DynamicImage
24
36
 
25
37
  private
26
38
 
39
+ def crop_attributes
40
+ %i[crop_width crop_height crop_start_x crop_start_y
41
+ crop_gravity_x crop_gravity_y]
42
+ end
43
+
27
44
  def rotate_dimensions(width, height, degrees)
28
45
  (degrees / 90).times do
29
46
  width, height = height, width
@@ -64,6 +81,7 @@ module DynamicImage
64
81
  self.data = processed_image.normalized do |image|
65
82
  yield(image) if block_given?
66
83
  end
84
+ read_image_metadata
67
85
  self
68
86
  end
69
87
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DynamicImage
4
- VERSION = "2.0.15".freeze
4
+ VERSION = "2.0.16".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails