Question

The goal is to validate an image based on dynamic height and width parameters, as well as DPI.

ImageMagick has the following command Identify which has a number of options.

-density

will generate the geometry widthxheight

-verbose

will generate a helpful "Print size: " and "Resolution"... among 78 other different lines... where width and height need to be parsed out to meet minimum requirements +/- 2%

so how does one extract those into a method, without stepping on intermediate toes (mini-magick)?

Was it helpful?

Solution

As the section on meta-information indicates, MiniMagick accesses the data using ImageMagick function in a single call, for example height density:

image["%y"]

ImageMagick has 47 single-letter attribute percent escapes that allows extraction of the data, provided your call to the image contains a ".path" suffix

image = MiniMagick::Image.open(@yourClass.theColumn.path)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top