Why is the degree behavior (imagemagick) not uniform on my machines?

I use a degree in rmagick / imagemagick to center images on canvas of a specific size.

On some of my cars, he centers them - on others, this is the opposite. If I fix the code to work on the same machine, it does the opposite.

Does anyone know why this is happening?

+4
source share
1 answer

I really already knew the answer - after 5 hours, struggling with the code. Just send this for reference.

For some unknown (and I think stupid) reason, this appeared in the ImageMagick change log:

2010-09-13 6.6.4-2 Cristy < quetzlzacatenango@image... > # Don't negate the geometry offset for the -extent option. 

For some reason, the ImageMagick team decided that it would be nice to change the function to make LITERALLY EXACT OPPOSITE OF WHAT HISTORICALLY MADE in the release.

The function should be left as it is, an investigative function with a new behavior can be introduced, and the original function is deprecated - with warnings - for several issues.

A strategy such as this, which is pretty much the standard way of handling such changes, would allow those with active code created against ImageMagick to continue as usual. Instead, people should now write code that supports both versions of this feature, or force updates.

the following ruby ​​code is an example of how to handle this, since you do not have NO IDEA WHATSOEVER, which version someone will run on their machine.

 offset_coords= { 'x' => 100 , 'y' => 100 } expects_negated = true # ImageMagick 6.6.4-2 changed the behavior of extent # me: !(*@&#(#! . #mversion = "ImageMagick 6.6.4-1 2010-12-07 Q16 http://www.imagemagick.org" mversion = Magick::Magick_version ( v_version , v_commit ) = mversion.split(' ')[1].split('-') ( v_version_1 , v_version_2 , v_version_3 ) = v_version.split('.') if Integer(v_version_1) >= 6 and Integer(v_version_2) >= 6 and Integer(v_version_3) >= 4 and Integer(v_commit) >= 2 expects_negated= false end if expects_negated offset_coords['x'] = - offset_coords['x'] offset_coords['y'] = - offset_coords['y'] end @new_image.background_color= "#000000" @new_image = @new_image.extent( target_dimensions['w'] , target_dimensions['h'] , offset_coords['x'] , offset_coords['y'] ) 
+5
source

Source: https://habr.com/ru/post/1334608/


All Articles