Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing of identify output failing with imagemagick 6.9.11.24 #518

Closed
boutil opened this issue Aug 25, 2020 · 2 comments
Closed

parsing of identify output failing with imagemagick 6.9.11.24 #518

boutil opened this issue Aug 25, 2020 · 2 comments

Comments

@boutil
Copy link
Contributor

boutil commented Aug 25, 2020

Hi!

When running the tests in Debian, we noticed some tests failures due to a change of output in the verbose identify output with the clipping_path.jpg image in spec/fixtures with Imagemagick 6.9.11.24.

See:
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=966436
and
ImageMagick/ImageMagick6#90

Indeed, the properties now contain the information about the clipping path as a subfield (in addtition to the Clipping path: field.

The logic in the details method in lib/mini_magick/image/info.rb now fails as when the level is -1, the details_hash[last_keys] can be a Hash and not a string in the case of the nested clipping path info inside properties, and the << operator fails.

I came up with this ugly hack to accomodate with the new output

--- ruby-mini-magick-4.9.5.orig/lib/mini_magick/image/info.rb
+++ ruby-mini-magick-4.9.5/lib/mini_magick/image/info.rb
@@ -136,7 +136,13 @@ module MiniMagick
               # indentation, resulting in a level of -1
               last_key = details_hash.keys.last
               details_hash[last_key] = '' if details_hash[last_key].empty?
-              details_hash[last_key] << line
+              # hack to accomodate with newer identify output
+              if details_hash[last_key].class==Hash
+                fkey = details_hash[last_key].keys.first
+                details_hash[last_key][fkey] << line
+              else
+                details_hash[last_key] << line
+              end
               next
             end

I know from the warning that parsing identify output is deprecated for imagemagick, but as it is used in several tests, it is important to ensure for now that it works ok so that failures detect real problems.

@janko
Copy link
Member

janko commented Nov 6, 2020

Are you able to use MiniMagick::Image#data instead? This one avoids parsing the verbose output, and parses JSON instead.

@janko
Copy link
Member

janko commented Jun 7, 2024

I'm done with attempting to correctly parse the verbose output. Everyone should just use MiniMagick::Image#data, assuming that ImageMagick dumps valid JSON.

@janko janko closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants