I'm using ImageMagick to generate some product badges for products in our system. Product badges are like SO flair, just a few composite images and some text. There is nothing wrong with the script as it runs fine on my development machine which runs Windows. However, on my production system (CentOS 5.1), it renders everything except the text.
I thought this was a font issue, but it doesn't work even if I copy the font file to the PHP file location nor did it work when I gave it a full path.
And it didn't work when I installed the Windows fonts for Linux as described here.
I've typed convert -list font and it shows a list of fonts that Imagick knows about (parital list shown below)
Font: Times-BoldItalic
family: Times
style: Italic
stretch: Normal
weight: 700
glyphs: /usr/share/fonts/default/Type1/n021024l.pfb
Font: Times-Italic
family: Times
style: Italic
stretch: Normal
weight: 400
glyphs: /usr/share/fonts/default/Type1/n021023l.pfb
Font: Times-Roman
family: Times
style: Normal
stretch: Normal
weight: 400
glyphs: /usr/share/fonts/default/Type1/n021003l.pfb
I tried giving the absolute path listed here and it didn't work. I also tried just using the name and still nothing.
Basically the image shows up, but the text parts of it don't show up at all and no errors are thrown (see images below).
There's nothing wrong with the code and both Windows and CentOS are running close versions of Imagick (6.7.1-4 and 6.7.1-3). The only issue could be the font, I'm just putting normal TTF fonts up and testing, do I need some kind of special font to get it to work?
Working
Broke
EDIT - Ignore the differences in the QR code and the ratings. This is due to the working badge and the non working badge being on two different servers.
UPDATE 1 - I've run a simple test script and even that doesn't work. This is what I ran as a test : http://us2.php.net/manual/en/function.imagick-annotateimage.php The font just doesn't show up and no errors are thrown.
I've also copied a font from the CentOS system and tried it on the Windows box and it works fine. Fonts simply don't seem to work on CentOS.
I've also tried it without setting a font, I assume Imagick picks up a default font or something, and again works on Windows, but not on CentOS. I'm going to try this on a different *nix version to see what happens. Will update with findings.
Update 3 : I've narrowed the issue down to a problem with the FreeType library I think. The forums say that FreeType needs to be installed for text to be displayed properly. And when I look at the config.log it tells me that there is an issue installing FreeType. Any heads up on this would be appreciated, meanwhile I'm going to re-install Freetype and run the installation again.
You can't just install Freetype. You actually have to install Freetype on your server, then recompile ImageMagick using the --with-freetype-dir=/usr/local option. Where /usr/local is the path to your Freetype install.
I believe it's normally /usr/local/bin
Give that a whirl and let us know what happens ;)
Related
My client needs to upload high-res images for her online press kit.
She is getting this error: "Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels."
The images she wants to upload are about 2.5MB in size, and are 4272 x 2848 with 72dpi.
If I crop the images, to be 2500x1667 at 72dpi, they upload fine (meeting the 2500 pixel suggested max size.)
Is there a way to allow the larger pixel images as indicated above (4272 x 2848)?
I am not sure which php setting is the issue - I think it might be memory size, but if it is, I am not sure where to change it or what amount to set it to, to allow twice the pixel max size allowance (going from 2500 to say 5000 pixels)... or if that is even allowed.
Any help would be appreciated.
Here are my system details:
WordPress Version: 5.5.1
MySQL Version: 5.6.41
BootStrap Version: 3.3.1
PHP version 7.3.22 (Supports 64bit values)
PHP max input variables 1000
PHP time limit 30
PHP memory limit 256M
Max input time 60
Upload max filesize 256M
PHP post max size 260M
Thanks!
I ran into this problem. Disabling big_image_size_threshold didn't fix it. I think my issue is that after upgrading to PHP 7.4, the version of ImageMagick running on my host for PHP 7.4 is bad or something. I fixed the issue by using GD instead of ImageMagick. Just add this to functions.php:
add_filter('wp_image_editors', function($editors) {
return ['WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'];
});
One thing to note: If you don't have GD installed, WP will default back to using Imagick. So there's little risk in making this change. Though if it doesn't resolve the problem, you might want to check that GD is actually installed.
You can use the big_image_size_threshold filter to change or disable this behavior.
https://developer.wordpress.org/reference/hooks/big_image_size_threshold/
If the original image width or height is above the threshold, it will be scaled down. The threshold is used as max width and max height. The scaled down image will be used as the largest available size, including the _wp_attached_file post meta value.
Returning false from the filter callback will disable the scaling.
This verified answer didn't work for me
The apache2 errors should be always in your
/var/log/apache2/error.log
So, you can identify the problem easily.
I fixed it by myself:
sudo apt-get install php-mbstring
sudo service apache2 restart
See this post there are many solutions for this: Link
I encountered this same issue and struggled with it for nearly a whole day - trying answers from this page and from this WordPress topic also: https://wordpress.org/support/topic/post-processing-of-the-image-failed-error/
Eventually, what resolved the problem for me was that I went to the WordPress Updates page and simply Re-installed WordPress - everything has been perfectly fine since.
I am running a network on WP version 5.7 with php 7.3
Main case : if you using any plugin in WordPress For image compress then its happens
in my case i was using WP Compress in WordPress i get most of this error when uploading image , after all i deactivate this plugin & problem fixed .
its been 3 days of research, google and frustration to make imagick work on my XAMPP box. I can get as far on making it as php module. But it cannot detect supported formats.
As you can see, I currently have 3.1.2 installed, but I actually worked all the way from the most recent 3.4.1 and jumping from those releases tagged with stable but I just can't make it work.
When I try to run:
<?php
$handle = fopen('http://xxxxx.png', 'rb');
$img = new Imagick();
$img->readImageFile($handle);
$img->thumbnailImage(100, 0);
echo $image;
I am getting:
Uncaught exception 'ImagickException' with message 'Unable to read image from the filehandle' in xxxxx:5 Stack trace: #0 xxxxx\index.php(5): Imagick->readimagefile(Resource id #3) #1 {main} thrown in xxxxx\index.php on line 5
What I have is:
Windows 8.1 64-bit
PHP 5.6.12, x86, TS
(http://i.imgur.com/2pnneqO.png)
This is what I actually have done so far, in terms of installing it:
Download any -Thread Safe (TS) x86 package from
https://pecl.php.net/package/imagick
Extract the .zip (1) php_imagick.dll to C:\_XAMPP\php\ext (2)
Extract CORE_RL_* files to C:\_xampp\apache\bin
Download ImageMagick-7.0.1-1-Q16-x86-dll.exe from
Link
Installed it at C:\ImageMagick
Add MAGICK_HOME to environment PATH. http://i.imgur.com/jQAWl3W.png
All *_.dll file in C:\ImageMagick\modules\coders copy to
C:\_Xampp\apache\bin
All *_.dll file in C:\ImageMagick\modules\coders copy to
C:\ImageMagick\
Restart Apache via Xampp
And still can't make my PHP detect Imagick supported file formats even though they should be http://prntscr.com/b1l54u :((
Can somebody tell me what did I miss? Please?
You seem to be going a bit of a convoluted route.
The method I used to install it when I had it running was:
Download and install Ghostscript with an exe file
Download and install imagemagick with an exe file - make sure you let it add the path to the environmental variables. You may not need this step but I wanted to use Imagemagick I'm my website and on my computer anyway.
Download the Imagick dll file and put it in the recommended folder - I can not remember which now.
Uncomment the Imagick option in the php.ini file. I had
two or three php.ini files on my system and I did it in each one.
Turned off the computer and restarted. Started XAMPP and it worked.
This only worked for a couple of installs and when I upgraded the operating system I could not get it to work due to incompatible versions of php and the Imagick.dll. If I should ever want to use Imagick I would do it on my server as the hosts installed it there for me.
You can still write your code locally and test it on your production server. It is a bit of a pain but would probably be quicker/easier than trying to get Imagick working on your PC.
Out of interest I gave up with it and use Imagemagick with exec() and the command line.
I am using a PHP Thumbnail Generating script that I have used without issue many times in the past. I am currently using it without issue on the very same domain that I am now having problems.
The script is processing to a point. It is generating physical thumbnail images and saving them into the preset cache directory but it is not returning resized images to the browser.
The image src is in the following format:
<img src="thumbnail.php?file=sample/02.jpg&w=100&h=70&el=0&gd=0" />
I have confirmed that the image exists and can be displayed in a browser itself.
Also, the PHP script loads ok as I have tested it by adding an 'echo' to confirm.
I have installed this script in multiple locations on the server and the result is the same. I have even tried other versions of PHP Thumbnail Generators and none of them produce resized images in the browsers.
I have checked that GD is active on my server:
GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.2
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.44
WBMP Support enabled
XBM Support enabled
PHP is version 5.3.29
Imagemagick is available and path confirmed as '/usr/bin/convert/'.
Here you see the result:
http://demos.mitey.co.nz/image_processor/index.php
All that appears is broken image placeholders instead of the dynamically generated thumbnails.
All relevant permissions have be set to 0777 or 0755, tried both.
This really isn't a difficult script to use and I have numerous times in the past but I am unable to debug whatever is causing it to fail in this instance.
Anybody have any ideas as to what could be stopping the image source from correctly processing the PHP contained within it?
I have tried so many different things that I can no longer focus on the issue and come up with anything else to try.
SOLVED: I was trying to load images into the script from another sub-domain. The Thumbnail script I was using claims to allow loading images from another domain using http however it thens fails when it comes to the PHP function 'file_exists' which does not work via the http protocol. I removed the 'http://' part of the image path using 'str_replace' and replaced it with the file system path, i.e. /home/siteroot/' and all works as expected. When used with images on the same domain as the thumbnail generating script the script is happy for the full 'http://' path to remain. There was no useful error messages to point this out.
Download the latest PHPthumb from website
For generate thumb see documentation
don't forget to Change variable as per your need.
$thumbUrl = "somefolder/new.jpg";
$resizeWidth = "70"; // in pixels
$resizeHeight = "70"; // in pixels
$imageThumb = $directoryPath. "/phpThumb/phpThumb.php?src=" . $thumb1 . "&w=".$resizeWidth."&h=".$resizeHeight."&iar=1&hash=90e9d46c4d138a72574c52e31fbef0dc";
echo '<img src="'.$imageThumb.'" alt="filename.jpg" />';
I'm having a strange problem with my vagrant setup: changing characters in a file and saving it doesn't reflect the change in the vm. But if I add/remove some characters or add in a few blank links, everything works fine.
I have already checked if I have opcache enabled on my PHP5.5 and "php -i | grep opcache" get any result ... so I imagine it's no.
Already tested too another vagrant (1.7.2) version, same result.
My configuration is :
Windows 7 Pro
Vagrant 1.6.3 with plugin WinNFSd
VirtualBox 4.3.12
Centos6.5 Box
PHP 5.5.19
Apache 2.4.10
PhpStorm 8 (but problem is same with SublimeText 3 and Notepad++)
Here is a video of a test from me for show you the problem :
https://www.dropbox.com/s/k70fiwfw6mopjs7/2015-03-24%2020-47-07.mp4?dl=0
Two weeks I work on this problem, it will make me crazy ...
I already tried Rsync and Samba or default vagrant synch folder but it doesn't meet my needs.
I really appreciate your help guys!
The problem on sublime was atomic_save setting being true. Not sure if there is an equivalent setting for PHPStorm/Notepad++
https://github.com/mitchellh/vagrant/issues/3888
I'm looking to use image masks in Typo3. After trying out various things and none of them worked, I decided to check out the install tool.
Install tool says ImageMagick is installed correctly, paths are correct and all image test complete successfully, except the convert/combine test. The test says "There was no result from the ImageMagick operation".
Also, when I'm using gifbuilder to output an image the image's dimensions get read correctly, allthough the outputted image stays blank. (which is white or another color when I have backColor set)
I am using:
Max OSX 10.7.5
XAMPP
PHP 5.3.1
Typo3 6.0.4
ImageMagic 6.7.3-2
Here is some test typoscript code (which on my install results in a fully red image instead of the original image)
lib.test = IMAGE
lib.test {
file = GIFBUILDER
file {
XY = [10.w],[10.h]
backColor = #FF0000
10 = IMAGE
10.file = fileadmin/user_upload/test.jpg
}
}
Attached is the result from the combining images test.
Does anyone have an idea as to what I might be doing wrong?
Some newer imagemagick versions use composite as command instead of combine. There is an option in the install tool to set the command to use. The setting is called [GFX][im_combine_filename].