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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

MiniMagick can't deal with ImageMagick 7 on specific resize value #553

Closed
felipeorlando opened this issue Jan 19, 2023 · 4 comments
Closed

Comments

@felipeorlando
Copy link

Hey hey, I need your help 馃檹

TL;DR

I'm receiving the following error when I try to resize something with the value 1600x1066>:

~ magick convert logo.png -auto-orient -resize 1600x1066> new-logo.heic
~ convert:  `1600x1066' @ error/convert.c/ConvertImageCommand/3339.

Some context:

My app configs:

Rails 7.0.4
Ruby 3.2.0
MiniMagick 4.12.0

ImageMagick 7: I have updated ImageMagick to version 7 because I wan't to accept HEIC images on my app. You can check the script I ran on the server to install IM7 with it's dependencies to run with HEIC and WEBP additionally to common formats:

Expand
sudo apt install build-essential autoconf git-core libtool make gcc -y
sudo apt install libx11-dev libxext-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev libxml2-dev -y
sudo apt build-dep imagemagick libmagickcore-dev libde265 libheif

mkdir -p /tmp/magick-installation
cd /tmp/magick-installation

git clone https://github.com/strukturag/libde265.git
git clone https://github.com/strukturag/libheif.git
git clone https://chromium.googlesource.com/webm/libwebp

for lib in libde265 libheif libwebp; do
  cd /tmp/magick-installation/$lib
  sudo ./autogen.sh
  sudo ./configure
  sudo make -j$(nproc)
  sudo make install
done

cd /tmp/magick-installation

wget https://www.imagemagick.org/download/ImageMagick-7.1.0-57.tar.gz
tar -xvf ImageMagick-7.1.0-57.tar.gz
cd ImageMagick-7.1.0-57
sudo ./configure --with-modules --with-heic=yes --with-webp=yes
sudo make -j$(nproc)
sudo make install
sudo ldconfig /usr/local/lib
sudo rm -rf /tmp/magick-installation

Also I have set the MiniMagick to use ImageMagick to use the 7th version, creating an initializer config file on my Rails app:

MiniMagick.configure do |config|
  config.cli = :imagemagick7
end

Problem

I'm receiving the following error when I try to resize something with the value 1600x1066>, and the output with magick is the following:

~ magick convert logo.png -auto-orient -resize 1600x1066> new-logo.heic
~ convert:  `1600x1066' @ error/convert.c/ConvertImageCommand/3339.

But if I run the resize value with proper quotation marks it works as you can see:

image

@janko
Copy link
Member

janko commented Jan 19, 2023

OK, it appears that for your shell > is a special character, so you need the quotes. Where is the MiniMagick problem here? MiniMagick bypasses the shell when running the ImageMagick command, so it doesn't have these issues.

@foolem
Copy link

foolem commented Jan 19, 2023

Hi @janko, I'll chime in here too, I and @felipeorlando work together.

So, this issue happens when we use the ImageProcessing gem (I see it's your creation, thank you!) to resize an image.

original_pipeline = ImageProcessing::MiniMagick.source(file)
large = original_pipeline.resize_to_limit!(1600, 1066)

That's where the error is raised:
convert: 1600x1066 @ error/convert.c/ConvertImageCommand/3339.

But running the command directly on the shell with quotes, it works.

We use UIbuntu 20.04 on the server where this error happens. Do you happen to know any chance we could use quotes for that command and still use the ImageProcessing gem with MiniMagick?

Thanks.

@janko
Copy link
Member

janko commented Jan 19, 2023

So, when you run the following command from Ruby on the server, you get the same error?

system *%W[magick convert logo.png -auto-orient -resize 1600x1066> new-logo.heic]

This is essentially what MiniMagick runs under-the-hood. Notice the special syntax where we pass the command as a list of positional arguments, which should tell Ruby to skip the shell and execute the command straight on the Kernel (avoiding the need to shell-escape anything).

@janko
Copy link
Member

janko commented Jun 7, 2024

Since I couldn't reproduce it, I'm closing this issue for now.

@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

3 participants