A
A
Alexander Knyazev2016-06-03 16:01:55
PHP
Alexander Knyazev, 2016-06-03 16:01:55

How to make the Imagick module built into the local Open Server work?

Installed openserver. I switched to it from Denwer, because I could not install Imagick there, but here it is built-in. But for some reason he does not want to work, as if he does not need any module. I upload the script to the hosting, it works there, but still developing on the hosting is inconvenient.
Maybe Imagick needs to be enabled somehow? I haven't found anything about it on the internet though.
Php_info tells you that Imagick is connected.
After adding the path to the folder in which Imagick is installed in the Path in the computer properties, the convert function works via cmd. But I need through php
When I try to insert such code:

<?php
$image = new Imagick('im.jpg');
// Если в качестве ширины или высоты передан 0,
// то сохраняется соотношение сторон
$image->thumbnailImage(100, 0);
?>

The script gives the following error:
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `im.jpg': No such file or directory @ error/blob.c/OpenBlob/2709' in F:\OpenServer\domains\ Mozart\php_info.php:4 Stack trace: #0 F:\OpenServer\domains\Mozart\php_info.php(4): Imagick->__construct('im.jpg') #1 {main} thrown in F:\OpenServer \domains\Mozart\php_info.php on line 4
I read that it might be necessary to specify the full path to the file, I did this: I got the following: Fatal error: Uncaught exception 'ImagickException' with message 'Failed to read the file' in F:\OpenServer \domains\Mozart\php_info.php:4 Stack trace: #0 F:\OpenServer\domains\Mozart\php_info.php(4): Imagick->__construct(' mozart/i...
$image = new Imagick('http://project/im.jpg');
') #1 {main} thrown in F:\OpenServer\domains\Mozart\php_info.php on line 4

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim Timofeev, 2016-06-03
@alexandrknyazev13071995

You need to provide the path, not the url.

http://project/im.jpg
- this is url.

A
Anton, 2016-06-03
@Yadalay

In what case is the message that Imagick is not connected shown?
I faced such problem earlier when I worked with the terminal in PhpStorm'e. I also use OpenServer.
I solved that question as follows:
1. Right key on the icon OpenServer'a.
2. Settings - "Bookmarks" tab.
2.1. Name - any name (I used PhpStorm).
2.2. Category - any (I used a new one - IDE).
2.3. Run - path to PhpStorm's exe.
3. Add.
4. Save.
5. Reboot the server.
6. Launch PhpStorm via bookmarks, not from the desktop or start icon.
6.1. Right key on the OpenServer icon.
6.2. My bookmarks - category (which was indicated) - title (which was indicated).
After all this, I could use the terminal in PhpStorm without this error already.

D
Demin_Nick, 2017-12-01
@Demin_Nick

Under Windows imagick only sees absolute paths, __DIR__ is needed.
$image = new Imagick(__DIR__.'/file_name');

V
Vitaliy Jakim, 2017-12-16
@Jakim

If you work in CMS, use a constant for example DIR_IMAGE -OpenCart
If self-written or do not know constants, use $_SERVER['DOCUMENT_ROOT'] and then specify the path to the image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question