local-fastimage_resize 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/run_tests.yml +40 -0
- data/CHANGELOG.md +12 -0
- data/Dockerfile +0 -0
- data/README.md +1 -4
- data/docker-compose.yml +0 -0
- data/ext/fastimage_native_resize/fastimage_native_resize.c +53 -33
- data/lib/fastimage/resize/version.rb +1 -1
- data/lib/fastimage/resize.rb +7 -4
- metadata +6 -9
- data/.travis.yml +0 -18
- data/VERSION.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 243e8ce180a53059cba215f6a4b1457034bb5706045b476004f014221f6d86dc
|
|
4
|
+
data.tar.gz: d678da3e9f07dfc24a6a8ce7d7bb88ec87b34389d55b3ce33ba4942a9d39d3f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c18538a4743a66a9a400a95a0475a4ebbee1804d499989669525b16318fc26ffa72a8ba8cce51dcce4dac77b56b7ba4a0ad9a52ff133d3eaa865fe9adb98dff6
|
|
7
|
+
data.tar.gz: 48283a7eeb579649a3ea7ca4a792956c9720a99e292570b8818f8e45b64b8ad9acf4786570adb80bdf5d8d838c0f12fd37547b0a7fdcad9af9dcd86449dc9403
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Tests
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-24.04
|
|
13
|
+
|
|
14
|
+
# Debian images match the libgd our servers run. Ubuntu's libgd fails to
|
|
15
|
+
# read TIFF images with libtiff >= 4.5.1.
|
|
16
|
+
container: ruby:${{ matrix.image }}
|
|
17
|
+
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
image: ['3.4-trixie', '3.3-trixie', '3.1-bookworm', '2.7-bullseye']
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v7
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
# releases past their end of life are only available from archive.debian.org
|
|
27
|
+
if ! (apt-get update && apt-get -y install libgd-dev); then
|
|
28
|
+
. /etc/os-release
|
|
29
|
+
cat > /etc/apt/sources.list <<EOF
|
|
30
|
+
deb http://archive.debian.org/debian $VERSION_CODENAME main
|
|
31
|
+
deb http://archive.debian.org/debian-security $VERSION_CODENAME-security main
|
|
32
|
+
EOF
|
|
33
|
+
rm -f /etc/apt/sources.list.d/*
|
|
34
|
+
apt-get update
|
|
35
|
+
apt-get -y install libgd-dev
|
|
36
|
+
fi
|
|
37
|
+
- name: Install Ruby dependencies
|
|
38
|
+
run: bundle install
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# 3.5.0 - 2026-07-13
|
|
2
|
+
|
|
3
|
+
Support for resizing WebP images. The generated thumbnail is a WebP image,
|
|
4
|
+
preserving transparency.
|
|
5
|
+
|
|
6
|
+
# 3.4.1 - 2025-03-04
|
|
7
|
+
|
|
8
|
+
Improved error handling and memory management to fix segmentation faults that
|
|
9
|
+
could occur with malformed images.
|
|
10
|
+
|
|
11
|
+
Introduced a new `FastImage::Resize::ImageProcessingError` exception class
|
|
12
|
+
|
|
1
13
|
# 3.4.0 - 2021-02-10
|
|
2
14
|
|
|
3
15
|
Support for resizing TIFF images. Output of such an operation is always a PNG
|
data/Dockerfile
ADDED
|
File without changes
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Local FastImage Resize
|
|
1
|
+
# Local FastImage Resize 
|
|
2
2
|
|
|
3
3
|
This is a fork of the [FastImage
|
|
4
4
|
Resize](https://github.com/sdsykes/fastimage_resize) gem.
|
|
@@ -10,9 +10,6 @@ It features the following differences:
|
|
|
10
10
|
* Support for Exif orientation
|
|
11
11
|
* Minor changes to code organization
|
|
12
12
|
|
|
13
|
-
[](https://travis-ci.org/planio-gmbh/local-fastimage_resize)
|
|
15
|
-
|
|
16
13
|
## Installation
|
|
17
14
|
|
|
18
15
|
Add this line to your application's Gemfile:
|
data/docker-compose.yml
ADDED
|
File without changes
|
|
@@ -23,7 +23,9 @@ static VALUE fastimage_native_resize(
|
|
|
23
23
|
int trans = 0, x = 0, y = 0, f = 0;
|
|
24
24
|
|
|
25
25
|
in = fopen(filename_in, "rb");
|
|
26
|
-
if (!in)
|
|
26
|
+
if (!in) {
|
|
27
|
+
rb_raise(rb_eIOError, "Could not open input file: %s", filename_in);
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
switch(image_type) {
|
|
29
31
|
case 0: im_in = gdImageCreateFromJpeg(in);
|
|
@@ -31,51 +33,64 @@ static VALUE fastimage_native_resize(
|
|
|
31
33
|
case 1: im_in = gdImageCreateFromPng(in);
|
|
32
34
|
break;
|
|
33
35
|
case 2: im_in = gdImageCreateFromGif(in);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
if (im_in) {
|
|
37
|
+
trans = gdImageGetTransparent(im_in);
|
|
38
|
+
/* find a transparent pixel, then turn off transparency
|
|
39
|
+
so that it copies correctly */
|
|
40
|
+
if (trans >= 0) {
|
|
41
|
+
for (x=0; x<gdImageSX(im_in); x++) {
|
|
42
|
+
for (y=0; y<gdImageSY(im_in); y++) {
|
|
43
|
+
if (gdImageGetPixel(im_in, x, y) == trans) {
|
|
44
|
+
f = 1;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
43
47
|
}
|
|
48
|
+
if (f) break;
|
|
44
49
|
}
|
|
45
|
-
|
|
50
|
+
gdImageColorTransparent(im_in, -1);
|
|
51
|
+
if (!f) trans = -1; /* no transparent pixel found */
|
|
46
52
|
}
|
|
47
|
-
gdImageColorTransparent(im_in, -1);
|
|
48
|
-
if (!f) trans = -1; /* no transparent pixel found */
|
|
49
53
|
}
|
|
50
54
|
break;
|
|
51
55
|
case 3: im_in = gdImageCreateFromTiff(in);
|
|
52
56
|
break;
|
|
57
|
+
case 4: im_in = gdImageCreateFromWebp(in);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
fclose(in);
|
|
61
|
+
rb_raise(rb_eArgError, "Unsupported image type: %d", image_type);
|
|
53
62
|
}
|
|
54
63
|
|
|
64
|
+
fclose(in);
|
|
55
65
|
if (!im_in) {
|
|
56
|
-
|
|
57
|
-
return Qnil;
|
|
66
|
+
rb_raise(rb_eRuntimeError, "Failed to read image data from: %s", filename_in);
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
|
|
61
70
|
|
|
62
71
|
/* Handle orientation */
|
|
63
72
|
if (orientation == 5 || orientation == 6) {
|
|
64
|
-
|
|
73
|
+
gdImagePtr rotated = gdImageRotateInterpolated(im_in, 270.0, 0);
|
|
74
|
+
gdImageDestroy(im_in);
|
|
75
|
+
if (!rotated) {
|
|
76
|
+
rb_raise(rb_eRuntimeError, "Failed to rotate image (orientation %d)", orientation);
|
|
77
|
+
}
|
|
78
|
+
im_in = rotated;
|
|
65
79
|
}
|
|
66
80
|
if (orientation == 7 || orientation == 8) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
gdImagePtr rotated = gdImageRotateInterpolated(im_in, 90.0, 0);
|
|
82
|
+
gdImageDestroy(im_in);
|
|
83
|
+
if (!rotated) {
|
|
84
|
+
rb_raise(rb_eRuntimeError, "Failed to rotate image (orientation %d)", orientation);
|
|
85
|
+
}
|
|
86
|
+
im_in = rotated;
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
if (orientation == 2 || orientation == 5 || orientation == 7) {
|
|
75
90
|
gdImageFlipHorizontal(im_in);
|
|
76
91
|
}
|
|
77
92
|
if (orientation == 3) {
|
|
78
|
-
|
|
93
|
+
gdImageFlipBoth(im_in);
|
|
79
94
|
}
|
|
80
95
|
if (orientation == 4) {
|
|
81
96
|
gdImageFlipVertical(im_in);
|
|
@@ -100,15 +115,14 @@ static VALUE fastimage_native_resize(
|
|
|
100
115
|
|
|
101
116
|
|
|
102
117
|
im_out = gdImageCreateTrueColor(w, h); /* must be truecolor */
|
|
103
|
-
if (im_out) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return Qnil;
|
|
118
|
+
if (!im_out) {
|
|
119
|
+
gdImageDestroy(im_in);
|
|
120
|
+
rb_raise(rb_eRuntimeError, "Failed to create output image buffer");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (image_type == 1 || image_type == 4) {
|
|
124
|
+
gdImageAlphaBlending(im_out, 0); /* handle transparency correctly */
|
|
125
|
+
gdImageSaveAlpha(im_out, 1);
|
|
112
126
|
}
|
|
113
127
|
|
|
114
128
|
/* Now copy the original */
|
|
@@ -117,7 +131,11 @@ static VALUE fastimage_native_resize(
|
|
|
117
131
|
gdImageSX(im_in), gdImageSY(im_in));
|
|
118
132
|
|
|
119
133
|
out = fopen(filename_out, "wb");
|
|
120
|
-
if (out) {
|
|
134
|
+
if (!out) {
|
|
135
|
+
gdImageDestroy(im_in);
|
|
136
|
+
gdImageDestroy(im_out);
|
|
137
|
+
rb_raise(rb_eIOError, "Could not open output file: %s", filename_out);
|
|
138
|
+
}
|
|
121
139
|
switch(image_type) {
|
|
122
140
|
case 0: gdImageJpeg(im_out, out, jpeg_quality);
|
|
123
141
|
break;
|
|
@@ -132,9 +150,11 @@ static VALUE fastimage_native_resize(
|
|
|
132
150
|
break;
|
|
133
151
|
case 3: gdImagePng(im_out, out);
|
|
134
152
|
break;
|
|
153
|
+
case 4: gdImageWebp(im_out, out);
|
|
154
|
+
break;
|
|
135
155
|
}
|
|
136
156
|
fclose(out);
|
|
137
|
-
|
|
157
|
+
|
|
138
158
|
gdImageDestroy(im_in);
|
|
139
159
|
gdImageDestroy(im_out);
|
|
140
160
|
return Qnil;
|
data/lib/fastimage/resize.rb
CHANGED
|
@@ -26,11 +26,14 @@ require 'fastimage'
|
|
|
26
26
|
require 'fastimage_native_resize'
|
|
27
27
|
|
|
28
28
|
module FastImage::Resize
|
|
29
|
-
SUPPORTED_FORMATS = [:jpeg, :png, :gif, :tiff]
|
|
30
|
-
FILE_EXTENSIONS = [:jpg, :png, :gif, :tiff] # prefer jpg to jpeg as an extension
|
|
29
|
+
SUPPORTED_FORMATS = [:jpeg, :png, :gif, :tiff, :webp]
|
|
30
|
+
FILE_EXTENSIONS = [:jpg, :png, :gif, :tiff, :webp] # prefer jpg to jpeg as an extension
|
|
31
31
|
|
|
32
32
|
class FormatNotSupported < FastImage::FastImageException # :nodoc:
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
class ImageProcessingError < FastImage::FastImageException # :nodoc:
|
|
36
|
+
end
|
|
34
37
|
|
|
35
38
|
def self.included(base)
|
|
36
39
|
base.extend ClassMethods
|
|
@@ -79,11 +82,11 @@ module FastImage::Resize
|
|
|
79
82
|
|
|
80
83
|
FastImage.native_resize(path, file_out.to_s, width.to_i, height.to_i, type_index, jpeg_quality.to_i, orientation)
|
|
81
84
|
|
|
82
|
-
raise FastImage::ImageFetchFailure, 'Image could be created' unless File.exist?(file_out.to_s)
|
|
85
|
+
raise FastImage::ImageFetchFailure, 'Image could not be created' unless File.exist?(file_out.to_s)
|
|
83
86
|
|
|
84
87
|
temp_file
|
|
85
88
|
rescue RuntimeError => e
|
|
86
|
-
raise FastImage::
|
|
89
|
+
raise FastImage::Resize::ImageProcessingError, e.message
|
|
87
90
|
end
|
|
88
91
|
end
|
|
89
92
|
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: local-fastimage_resize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen Sykes
|
|
8
8
|
- Gregor Schmidt (Planio)
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: local-fastimage
|
|
@@ -92,15 +91,16 @@ extensions:
|
|
|
92
91
|
- ext/fastimage_native_resize/extconf.rb
|
|
93
92
|
extra_rdoc_files: []
|
|
94
93
|
files:
|
|
94
|
+
- ".github/workflows/run_tests.yml"
|
|
95
95
|
- ".gitignore"
|
|
96
|
-
- ".travis.yml"
|
|
97
96
|
- CHANGELOG.md
|
|
97
|
+
- Dockerfile
|
|
98
98
|
- Gemfile
|
|
99
99
|
- MIT_LICENCE
|
|
100
100
|
- README.md
|
|
101
101
|
- README.textile
|
|
102
102
|
- Rakefile
|
|
103
|
-
-
|
|
103
|
+
- docker-compose.yml
|
|
104
104
|
- ext/fastimage_native_resize/extconf.rb
|
|
105
105
|
- ext/fastimage_native_resize/fastimage_native_resize.c
|
|
106
106
|
- lib/fastimage/resize.rb
|
|
@@ -110,7 +110,6 @@ homepage: http://github.com/planio-gmbh/local-fastimage_resize
|
|
|
110
110
|
licenses:
|
|
111
111
|
- MIT
|
|
112
112
|
metadata: {}
|
|
113
|
-
post_install_message:
|
|
114
113
|
rdoc_options: []
|
|
115
114
|
require_paths:
|
|
116
115
|
- lib
|
|
@@ -126,9 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
125
|
version: '0'
|
|
127
126
|
requirements:
|
|
128
127
|
- libgd, see www.libgd.org
|
|
129
|
-
|
|
130
|
-
rubygems_version: 2.6.14.4
|
|
131
|
-
signing_key:
|
|
128
|
+
rubygems_version: 4.0.1
|
|
132
129
|
specification_version: 4
|
|
133
130
|
summary: Local FastImage Resize - Image resizing fast and simple
|
|
134
131
|
test_files: []
|
data/.travis.yml
DELETED