jekyll-auto-thumbnails 0.2.1 → 0.3.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +11 -1
- data/lib/jekyll-auto-thumbnails/generator.rb +10 -15
- data/lib/jekyll-auto-thumbnails/imagemagick_wrapper.rb +98 -0
- data/lib/jekyll-auto-thumbnails/scanner.rb +3 -1
- data/lib/jekyll-auto-thumbnails/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16ce03cdf3b6510927461c3ce6bc7c1ceb7e6146bdbf5ff5245b4c7926ab5cc9
|
|
4
|
+
data.tar.gz: 83656688c847d89c6f2319c3abe464453652c97536aadd081eb931ea8f07a94e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1c00316b696556de42b2c4b873becaa6b5dc95896e5c83599debbdb068947ff153682e881fcf3d6ede108fecb97d647f740c0d166c3f19e0c5649852e09e5cc
|
|
7
|
+
data.tar.gz: e2631ed452176bf5bdfccfad0b7f079bfb62578fc4d898f3e92dae0178cf015a392d3ab2f217cd35ef4b41fc0c3a3f56e4d8e745dbec2b9b76f7bbc38bc9e3bf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/Texarkanine/jekyll-auto-thumbnails/compare/v0.2.1...v0.3.0) (2025-12-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Handle imagemagick 6 or 7 interface ([#4](https://github.com/Texarkanine/jekyll-auto-thumbnails/issues/4)) ([345ac4c](https://github.com/Texarkanine/jekyll-auto-thumbnails/commit/345ac4caf45a7d112d02fb394ad58759083448cc))
|
|
9
|
+
|
|
3
10
|
## [0.2.1](https://github.com/Texarkanine/jekyll-auto-thumbnails/compare/v0.2.0...v0.2.1) (2025-12-11)
|
|
4
11
|
|
|
5
12
|
|
data/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Automatic Image Thumbnails for Jekyll
|
|
2
2
|
|
|
3
|
+
[](https://rubygems.org/gems/jekyll-auto-thumbnails)
|
|
4
|
+
[](https://codecov.io/gh/Texarkanine/jekyll-auto-thumbnails)
|
|
5
|
+
|
|
3
6
|
Scans your rendered HTML for local images with `width` or `height` attributes, then automatically generates and uses appropriately-sized thumbnails for them, if the `src` image is bigger than that.
|
|
4
7
|
|
|
5
8
|
Can also take global maximum dimensions (such as for fixed-width layouts) and thumbnail images that don't have explicit size attributes, too.
|
|
@@ -22,7 +25,9 @@ Run:
|
|
|
22
25
|
bundle install
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
**System Requirement**: ImageMagick must be installed
|
|
28
|
+
**System Requirement**: ImageMagick must be installed. The gem supports both:
|
|
29
|
+
- **ImageMagick 6**: Uses `convert` and `identify` commands directly
|
|
30
|
+
- **ImageMagick 7**: Uses `magick convert` and `magick identify` (automatically detected)
|
|
26
31
|
|
|
27
32
|
## Configuration
|
|
28
33
|
|
|
@@ -104,9 +109,14 @@ sudo apt-get install imagemagick
|
|
|
104
109
|
brew install imagemagick
|
|
105
110
|
|
|
106
111
|
# Verify installation
|
|
112
|
+
# ImageMagick 6:
|
|
107
113
|
which convert identify
|
|
114
|
+
# ImageMagick 7:
|
|
115
|
+
which magick
|
|
108
116
|
```
|
|
109
117
|
|
|
118
|
+
The gem automatically detects which version you have installed and uses the appropriate commands.
|
|
119
|
+
|
|
110
120
|
### Thumbnails Not Generating
|
|
111
121
|
|
|
112
122
|
Check build output for warnings:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "fileutils"
|
|
4
|
+
require_relative "imagemagick_wrapper"
|
|
4
5
|
|
|
5
6
|
module JekyllAutoThumbnails
|
|
6
7
|
# Thumbnail generation via ImageMagick
|
|
@@ -16,15 +17,9 @@ module JekyllAutoThumbnails
|
|
|
16
17
|
|
|
17
18
|
# Check if ImageMagick is available (cross-platform)
|
|
18
19
|
#
|
|
19
|
-
# @return [Boolean] true if
|
|
20
|
+
# @return [Boolean] true if ImageMagick (v6 or v7) is available
|
|
20
21
|
def imagemagick_available?
|
|
21
|
-
|
|
22
|
-
path_dirs = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
|
|
23
|
-
|
|
24
|
-
path_dirs.any? do |dir|
|
|
25
|
-
executable = File.join(dir, cmd_name)
|
|
26
|
-
File.executable?(executable)
|
|
27
|
-
end
|
|
22
|
+
ImageMagickWrapper.available?
|
|
28
23
|
end
|
|
29
24
|
|
|
30
25
|
# Generate thumbnail (with caching)
|
|
@@ -95,19 +90,19 @@ module JekyllAutoThumbnails
|
|
|
95
90
|
geometry = build_geometry(width, height)
|
|
96
91
|
ext = File.extname(source_path)
|
|
97
92
|
|
|
98
|
-
# Build
|
|
99
|
-
|
|
93
|
+
# Build arguments array
|
|
94
|
+
args = [source_path, "-resize", geometry]
|
|
100
95
|
|
|
101
96
|
# Add quality for lossy formats
|
|
102
97
|
if quality_needed?(ext)
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
args << "-quality"
|
|
99
|
+
args << @config.quality.to_s
|
|
105
100
|
end
|
|
106
101
|
|
|
107
|
-
|
|
102
|
+
args << dest_path
|
|
108
103
|
|
|
109
|
-
#
|
|
110
|
-
|
|
104
|
+
# Use wrapper to execute convert (handles both v6 and v7)
|
|
105
|
+
ImageMagickWrapper.execute_convert(*args)
|
|
111
106
|
end
|
|
112
107
|
|
|
113
108
|
# Build ImageMagick geometry string
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
5
|
+
module JekyllAutoThumbnails
|
|
6
|
+
# Wrapper for ImageMagick commands supporting both version 6 and 7
|
|
7
|
+
#
|
|
8
|
+
# ImageMagick 6 uses `convert` and `identify` commands directly.
|
|
9
|
+
# ImageMagick 7 uses `magick convert` and `magick identify` (or `magick` with subcommands).
|
|
10
|
+
#
|
|
11
|
+
# This module detects the available version and provides a unified interface.
|
|
12
|
+
module ImageMagickWrapper
|
|
13
|
+
# Check if ImageMagick is available (either version 6 or 7)
|
|
14
|
+
#
|
|
15
|
+
# @return [Boolean] true if ImageMagick is available
|
|
16
|
+
def self.available?
|
|
17
|
+
version = detect_version
|
|
18
|
+
%i[v6 v7].include?(version)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get the convert command array for the detected ImageMagick version
|
|
22
|
+
#
|
|
23
|
+
# @return [Array<String>] command array (e.g., ["convert"] or ["magick", "convert"])
|
|
24
|
+
def self.convert_command
|
|
25
|
+
case detect_version
|
|
26
|
+
when :v7
|
|
27
|
+
%w[magick convert]
|
|
28
|
+
when :v6
|
|
29
|
+
["convert"]
|
|
30
|
+
else
|
|
31
|
+
["convert"] # Default fallback (will fail if not available)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get the identify command array for the detected ImageMagick version
|
|
36
|
+
#
|
|
37
|
+
# @return [Array<String>] command array (e.g., ["identify"] or ["magick", "identify"])
|
|
38
|
+
def self.identify_command
|
|
39
|
+
case detect_version
|
|
40
|
+
when :v7
|
|
41
|
+
%w[magick identify]
|
|
42
|
+
when :v6
|
|
43
|
+
["identify"]
|
|
44
|
+
else
|
|
45
|
+
["identify"] # Default fallback (will fail if not available)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Execute convert command with arguments
|
|
50
|
+
#
|
|
51
|
+
# @param args [Array<String>] arguments to pass to convert
|
|
52
|
+
# @return [Boolean] true if command succeeded
|
|
53
|
+
def self.execute_convert(*args)
|
|
54
|
+
cmd = convert_command + args
|
|
55
|
+
system(*cmd)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Execute identify command with arguments
|
|
59
|
+
#
|
|
60
|
+
# @param args [Array<String>] arguments to pass to identify
|
|
61
|
+
# @return [Array<String, Process::Status>] [output, status] tuple
|
|
62
|
+
def self.execute_identify(*args)
|
|
63
|
+
cmd = identify_command + args
|
|
64
|
+
Open3.capture2e(*cmd)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Detect which ImageMagick version is available
|
|
68
|
+
#
|
|
69
|
+
# @return [Symbol] :v6, :v7, or :none
|
|
70
|
+
def self.detect_version
|
|
71
|
+
return @detected_version if defined?(@detected_version) && @detected_version
|
|
72
|
+
|
|
73
|
+
@detected_version = if command_exists?("magick")
|
|
74
|
+
:v7
|
|
75
|
+
elsif command_exists?("convert")
|
|
76
|
+
:v6
|
|
77
|
+
else
|
|
78
|
+
:none
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Check if a command exists in PATH
|
|
83
|
+
#
|
|
84
|
+
# @param cmd [String] command name
|
|
85
|
+
# @return [Boolean] true if command found
|
|
86
|
+
def self.command_exists?(cmd)
|
|
87
|
+
cmd_name = Gem.win_platform? ? "#{cmd}.exe" : cmd
|
|
88
|
+
path_dirs = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
|
|
89
|
+
|
|
90
|
+
path_dirs.any? do |dir|
|
|
91
|
+
# Use File.join for cross-platform path construction
|
|
92
|
+
# On Unix, this will use forward slashes even for Windows-style paths in tests
|
|
93
|
+
executable = File.join(dir, cmd_name)
|
|
94
|
+
File.executable?(executable)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "nokogiri"
|
|
4
4
|
require "open3"
|
|
5
|
+
require_relative "imagemagick_wrapper"
|
|
5
6
|
|
|
6
7
|
module JekyllAutoThumbnails
|
|
7
8
|
# HTML scanning for images
|
|
@@ -78,7 +79,8 @@ module JekyllAutoThumbnails
|
|
|
78
79
|
def self.image_dimensions(file_path)
|
|
79
80
|
# Use ImageMagick identify command (shell-free, cross-platform)
|
|
80
81
|
# Use [0] to get only first frame (important for animated GIFs)
|
|
81
|
-
|
|
82
|
+
# Wrapper handles both ImageMagick v6 and v7
|
|
83
|
+
output, status = ImageMagickWrapper.execute_identify("-format", "%wx%h", "#{file_path}[0]")
|
|
82
84
|
return nil unless status.success? && !output.strip.empty?
|
|
83
85
|
|
|
84
86
|
width, height = output.strip.split("x").map(&:to_i)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-auto-thumbnails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Texarkanine
|
|
@@ -159,6 +159,7 @@ files:
|
|
|
159
159
|
- lib/jekyll-auto-thumbnails/digest_calculator.rb
|
|
160
160
|
- lib/jekyll-auto-thumbnails/generator.rb
|
|
161
161
|
- lib/jekyll-auto-thumbnails/hooks.rb
|
|
162
|
+
- lib/jekyll-auto-thumbnails/imagemagick_wrapper.rb
|
|
162
163
|
- lib/jekyll-auto-thumbnails/registry.rb
|
|
163
164
|
- lib/jekyll-auto-thumbnails/scanner.rb
|
|
164
165
|
- lib/jekyll-auto-thumbnails/url_resolver.rb
|