Rectangle 27 13

There are a number of reasons why your PNG images may be increasing in size, the most obvious one that you will run into is GM/IM's inability to convey transparency as a tRNS chunk (basically boolean transparency for PNG images). Unfortunately the maintainers of GraphicsMagick and ImageMagick have not implemented this feature yet. I exchanged emails with them so I know this for sure.

I know you don't want to use external tools but trust me you do. Image/GraphicsMagick are really bad at compressing PNG images. The solution I am using is, use GraphicsMagick to manipulate the image and also check if the image contains transparent pixels, if it does contain transparent pixels then run OptiPNG on the image. OptiPNG will see that transparency can be conveyed as a tRNS chunk and act accordingly. Actually you should run OptiPNG on all PNG images after using Image/GraphicsMagick because I have found that you can achieve much greater compression. You can also save space by turning dithering off and by using the YUV color space.

As for GM reducing the size of images better than IM, you should know that GM by default uses an 8 bit color space when color reducing images while ImageMagick by default uses 16 bits. This is why GM is so much faster than IM when color reducing images to a value over 255 colors. Maybe you should check the number of colors in each image after compression to confirm.

Oh, and here I was thinking Imagick was the swiss army knife of image manipulation... Guess I'll have to work around it when converting to PNG format. Thank you!

Your very welcome, As for your first question I think the only way to do that is to use your script to decide if the output image format supports transparency and if not set transparent pixels to white. Also check out imagemagick.org/Usage/formats/#color_profile for info on how to handle color profiles in IM.

image - Issues porting PHP/GD wrapper to Imagick - Stack Overflow

php image imagemagick gd imagick
Rectangle 27 10

Sounds like you might have unearthed a bug.

In the meantime, you could work around it by using __DIR__ or __FILE__ to construct an absolute path.

For example, to use the script's directory, do the following:

$im = new imagick (__DIR__ . DIRECTORY_SEPARATOR . 'a.jpg');

thank you, this workaround is working. actually, the better way (for me) is realpath('a.jpg'); it's working without any problems. i was just trying to figure out, if someone else had similar problem. i tried 2 different php_imagick.dll (i'm not able to compile it by myself under windows) and 4 different Imagick versions (installers) but i think this is not the real problem, because with absolute paths imagick is working fine.

Imagick PHP 5.4 extension does not work with relative paths. (windows)...

php windows relative-path imagick
Rectangle 27 3

I found the answer. To provide consistent bit depth in PNGs using imagick replace:

$shadowSwatch->setColorspace(13);
$shadowSwatch->setImageDepth(32);
$shadowSwatch->setOption('png:color-type', 6);
$shadowSwatch->setOption('png:bit-depth', 8);

Consistent PNG Bit output with PHP Imagick - Stack Overflow

php png fpdf imagick
Rectangle 27 4

Imagick calls the ImageMagick library to do all it's processing of images. The Image Magick library does not handle all images itself, it can delegate the rendering of them off to another library to process them. For PDF files it usually delegates to the GhostScript library.

From the command line, if you run convert -list configure you should be able to see what delegates are being used by ImageMagick, under the DELEGATES entry.

It looks like you are encountering a bug in Ghostscript. Trying to convert the PDF by directly calling GS version 8.70 with the command:

GPL Ghostscript 8.70: Some glyphs of the font ArialNarrow-Bold requires a patented True Type interpreter. GPL Ghostscript 8.70: Some glyphs of the font ArialNarrow requires a patented True Type interpreter. Error: /invalidaccess in --run-- Operand stack: --dict:8/17(L)-- F4 56.954 --dict:5/5(L)-- --dict:5/5(L)-- ArialMT --dict:11/12(ro)(G)-- --nostringval-- CIDFontObject --dict:6/6(L)-- --dict:6/6(L)-- 178279 --dict:6/6(L)-- --nostringval-- PDFCIDFontName ArialMT Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 13 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:1154/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:21/40(L)-- --dict:1/1(ro)(G)-- Current allocation mode is local GPL Ghostscript 8.70: Unrecoverable error, exit code 1

Upgrading to GhostScript 9.16 does not show this problem and the PDF is converted successfully.

(btw your PDF does not have a background layer, despite some of the text being anti-aliased to white.)

Thanks so much for the response. It certainly gave me somthing to go one. However, I kind of ran into a wall with it. I have some stuff that is hosted on siteground and when I have needed assistance with the software I would usually just submit a support ticket and request the change, and it would magically happen.

This page is hosted on a shared server at godaddy and I had tried to submit a ticket for a request, then I found out they they NO LONGER HAVE A TICKET SYSTEM AT ALL. So after 30 minutes waiting for online chat and then another 20 minutes waiting on hold, I got someone who insisted that they did not offer any support like that and that I would have to do that myself. So i logged in over secure shell and it was going fine until I got to the "make install" part, then I got a bunch of permission denied messages. So I assumed it wanted me to log in as root, but now I am realizing that I cant do

that on a shared server. So I seem to be stuck, they won't do it, I don't seem to have permission. I've a box open for their online chat saying "0 minutes" for the last hour and no one picking up. Go daddy support is the worst support I think Ive encountered in my life. So any advice?

You could try just downloading a precompiled binary from ghostscript.com/download otherwise, it sounds like you have outgrown the capabilities of a shared hosting company.

Converting PDF to JPG with PHP using imagick works with flat pdf but f...

php pdf imagick
Rectangle 27 3

This answer might be extremely naive, but, I've found that getting things done in Windows is generally too painful. Many people agree with that and have found solace in a tool known as "chocolatey".

Then, use chocolatey to install everything else that you need (imagemagick in this case):

I suspect you might have to do some minor tweaking to configuration files after that, plus handle all of the "Windows permissions" needed to get things to work smoothly. Permissions are can be as simple (and not necessarily safe) as "full control" to some user, plus activating inheritance and overwriting all children's settings to use inheritance.

php - How to install imagick in xampp/wampp in Windows - Stack Overflo...

php xampp imagemagick imagick
Rectangle 27 8

This is not a complete answer, but you are going about this completely wrong.

Fabric.js already has a way of saving a canvas to SVG format with the canvas.toSVG() function. Imagick can open SVG files and convert them to PNG at any quality you want.

There will be an issue when trying to include the bitmaps that are included in the image e.g.

"src": "http:\\example.com/images/3f0bc771261860d917e0ad6d09cb2064.png",

I would strongly recommend downloading these yourself on the server, rather than allowing Imagick to download them. Not only will that give you better control over any errors that may occur, but also limits some security risks. Allowing people to download arbitrary data from within your server and then having that data used by a library that has had many bugs with memory access is not a good idea.

The general way to do this would be to replace the src of the image with a reference to a local file name either before fabric.js creates the SVG or you could do it even more hackily after it's been converted - and when you do this replacement generate a list of files that need to be downloaded from a remote server.

The actual implementation details are left as an exercise for OP.

btw there is a reasonable chance someone has already done this....have you searched packagist/github thoroughly?

and i also tried toSVG method previous, which contains more issues (not only image data encoding ) even this simple text not converting correctly by Imagick <g transform="translate(131 221)"> <text font-family="Times New Roman" font-size="40" font-weight="normal" style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform="translate(-42 42)"><tspan x="0" y="-26" fill="rgb(0,0,0)">Suraj</tspan></text> </g>

You should post that as a separate questions under "Why does Imagick not convert this SVG generated by Fabric".

Imagick build version can be cause of reason for not convert fabricJS's SVG to png, but we could achieve it through exec( convert design.svg output.png ) BTW i want it through DataArray, And important thing my question is about "Calculate Offset on Rotation", isn't it..?

No your question is "How to create a high quality image from array of data" and the answer to that is to use SVG. If you have a specific question about rotations in Imagick, you should ask that a standalone simple question, tagged with Imagick.

math - PHP/Imagick: How to crate a large ( High Quality 300dpi ) image...

php math rotation imagemagick imagick
Rectangle 27 2

Double check the paths and php configuration - you might have the imagick.so file in another directory, not the one php is looking for extensions in ?

1) Locate the proper php.ini file - in your phpinfo() page it is pointed which php.ini is actually in use.

2) Make sure you have imagick.so in proper extension dir (the one php really uses). To check the actual path use:

3) if (1) and (2) are OK, enable the extension in php.ini

4) restart web server, the imagick should be present (loaded) in phpinfo()

Bear in mind that the following also apply

Your extension should compatible with your PHP server in three main attributes:

1- The Zend API number which your PHP server is configured with ( in phpinfo() you can find this number), this number should be the same with your extension header file at build time.

2- The compiler version on your PHP server and your extension must be the same.

3- Thread safety in your PHP server is important. If you use thread-safe server then your extension must be built with php thread-safe library and if you use non-thread safe server you should build your extension with PHP-nts library.

Keep in mind that if an .so file is corrupt, is improper in other ways (incorrect file structure) or depends on files that are missing or not available for load - the extension will not be loaded and made available.

Note that the "php -m" shows modules compiled into php, not the loaded extensions. Try the below for more detailed information:

Module compiled with module API=20090626 PHP compiled with module API=20121212

clearly indicates that you have the module compiled with improper API version that does not match the php. You will need to build the PHP extension manually. The extension you've ended up with seems to be built against a different version of PHP, not your current PHP 5.5.

There are numerous tutorials concerning this topic, just remember to use the proper version of imagick and phpize. This should help you out: http://wiki.dreamhost.com/ImageMagick_and_imagick_php_module_on_shared_hosting

Still i am facing the same issue. php.ini not loading imagick extension

I am not sure weather i am using php thread-safe library or not as well as not sure about extension also that it is thread-safe or not. Can you please tell me how to check it?

ubuntu - Imagick Not Loaded in PHP - Stack Overflow

php ubuntu imagick pecl
Rectangle 27 2

Double check the paths and php configuration - you might have the imagick.so file in another directory, not the one php is looking for extensions in ?

1) Locate the proper php.ini file - in your phpinfo() page it is pointed which php.ini is actually in use.

2) Make sure you have imagick.so in proper extension dir (the one php really uses). To check the actual path use:

3) if (1) and (2) are OK, enable the extension in php.ini

4) restart web server, the imagick should be present (loaded) in phpinfo()

Bear in mind that the following also apply

Your extension should compatible with your PHP server in three main attributes:

1- The Zend API number which your PHP server is configured with ( in phpinfo() you can find this number), this number should be the same with your extension header file at build time.

2- The compiler version on your PHP server and your extension must be the same.

3- Thread safety in your PHP server is important. If you use thread-safe server then your extension must be built with php thread-safe library and if you use non-thread safe server you should build your extension with PHP-nts library.

Keep in mind that if an .so file is corrupt, is improper in other ways (incorrect file structure) or depends on files that are missing or not available for load - the extension will not be loaded and made available.

Note that the "php -m" shows modules compiled into php, not the loaded extensions. Try the below for more detailed information:

Module compiled with module API=20090626 PHP compiled with module API=20121212

clearly indicates that you have the module compiled with improper API version that does not match the php. You will need to build the PHP extension manually. The extension you've ended up with seems to be built against a different version of PHP, not your current PHP 5.5.

There are numerous tutorials concerning this topic, just remember to use the proper version of imagick and phpize. This should help you out: http://wiki.dreamhost.com/ImageMagick_and_imagick_php_module_on_shared_hosting

Still i am facing the same issue. php.ini not loading imagick extension

I am not sure weather i am using php thread-safe library or not as well as not sure about extension also that it is thread-safe or not. Can you please tell me how to check it?

ubuntu - Imagick Not Loaded in PHP - Stack Overflow

php ubuntu imagick pecl
Rectangle 27 2

Double check the paths and php configuration - you might have the imagick.so file in another directory, not the one php is looking for extensions in ?

1) Locate the proper php.ini file - in your phpinfo() page it is pointed which php.ini is actually in use.

2) Make sure you have imagick.so in proper extension dir (the one php really uses). To check the actual path use:

3) if (1) and (2) are OK, enable the extension in php.ini

4) restart web server, the imagick should be present (loaded) in phpinfo()

Bear in mind that the following also apply

Your extension should compatible with your PHP server in three main attributes:

1- The Zend API number which your PHP server is configured with ( in phpinfo() you can find this number), this number should be the same with your extension header file at build time.

2- The compiler version on your PHP server and your extension must be the same.

3- Thread safety in your PHP server is important. If you use thread-safe server then your extension must be built with php thread-safe library and if you use non-thread safe server you should build your extension with PHP-nts library.

Keep in mind that if an .so file is corrupt, is improper in other ways (incorrect file structure) or depends on files that are missing or not available for load - the extension will not be loaded and made available.

Note that the "php -m" shows modules compiled into php, not the loaded extensions. Try the below for more detailed information:

Module compiled with module API=20090626 PHP compiled with module API=20121212

clearly indicates that you have the module compiled with improper API version that does not match the php. You will need to build the PHP extension manually. The extension you've ended up with seems to be built against a different version of PHP, not your current PHP 5.5.

There are numerous tutorials concerning this topic, just remember to use the proper version of imagick and phpize. This should help you out: http://wiki.dreamhost.com/ImageMagick_and_imagick_php_module_on_shared_hosting

Still i am facing the same issue. php.ini not loading imagick extension

I am not sure weather i am using php thread-safe library or not as well as not sure about extension also that it is thread-safe or not. Can you please tell me how to check it?

ubuntu - Imagick Not Loaded in PHP - Stack Overflow

php ubuntu imagick pecl
Rectangle 27 2

rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
yum install libjpeg-turbo dcraw perl-Image-ExifTool
yum install ufraw

then update the delegates.xml of imageMagick :

<delegate decode="dng:decode" command="&quot;ufraw-batch&quot; --silent --create-id=also --out-type=png --out-depth=16 &quot;--output=%u.png&quot; &quot;%i&quot;"/>

with the absolute path of ufraw-batch :

command="&quot;ufraw-batch&quot;
command="&quot;/usr/bin/ufraw-batch&quot;
locate ufraw-batch

In case it doesn't reveal the location, use :

echo $PATH

which will give you the folders where programs can be, and try an "ls" on each of them. You will find ufraw-batch and then its absolute path.

I spent 2 days to achieve that as I'm not used to playing with command lines. Hope it could help someone in the future.

php - Imagick exception "unable to open image" when converting a CR2 o...

php imagemagick imagick
Rectangle 27 2

You can use optipng (another PNG command-line tool) to optimize the size of your PNG files.

image - Issues porting PHP/GD wrapper to Imagick - Stack Overflow

php image imagemagick gd imagick
Rectangle 27 1

You have to put let PHP know the PATH to the ImageMagic.

You can manullay put that by adding this line in your PHP script.

putenv("PATH=your_path_to_the_bin_folder");

something similar depending on your setup. The gs executable has to be in your script user's path somewhere or ImageMagick will fail to convert PDF or EPS files.

I hope you have set that path for WINDOWS . But You must let know the PHP about the PATH. To do that you can include the PATH in the PHP Script.

You mean you can do the image conversion via PHP?

yes I can convert a jpg to png to a pdf but not pdf to jpg

iis - shell_exec and convert pdf to jpg with Imagick PHP - Stack Overf...

php iis pdf imagick
Rectangle 27 1

ImageMagick delegates PDF rendering to Ghostscript, therefore for troubleshooting specify not only IM, but GS version, too, if necessary. Second, I think it's better to start with command line, and only after appropriate quality is achieved, put it into php code.

Command that gives quality (more or less):

convert -density 300 all.pdf out.jpg

Here we set rendering resolution 300 dpi. Note, it's not the same as

convert all.pdf -density 300 out.jpg

But, I think better approach can be to extract scans as is i.e. without transformations:

pdfimages all.pdf all

that gives all-000.pbm image -- 1-bit per sample, 3424*4400 px. I definitely can't agree, that "text is clear and legible" - some digits can only be guessed.

convert
convert all-000.pbm -resize 25% -sharpen 2 out.jpg

Question for you...does this only work on pdf files that are image only? If the file was created by saving a document as a pdf would this not work?

@Jason, using pdfimages to convert a page works if a page is exactly one image. Otherwise render PDF to image with Ghostscript or another tool, including IM's convert (which uses GS).

How do I create a better quality image converting a .pdf to a .jpg wit...

php pdf imagick
Rectangle 27 1

As there is not much support for ICM in browsers the profiles are essentially a waste of bandwidth. Thus if your images are in sRGB you can safely trash the profile, otherwise it is better to convert an image into sRGB and trash its profile afterwards.

The reason for removing a profile of sRGB images is that sRGB is effectively a standard on the Internet, on computers, and on printers, and even Firefox applies sRGB color profile to untagged images.

There is another reason for removing all profiles altogether, thou I'm not sure if it applies to your case: if you're planning to mix images with embedded profiles with other profile-less images, e.g. GIF images, which cannot contain a profile by definition, you'll end up with a messy result on an ICC-enabled browser. It'll render some images as per their embedded color space and other with a some other color profile, which leads to a situation in which you'll see a boundary between an image with an embedded ICC profile with a solid background color adjoining other profile-less image with the same color background color. Even if you manage to get a profile for every image on your page, there are a lot of users who use ancient ICC-disabled browsers.

Bottom line: color profiles are evil. Only use them if you actually need them.

What I said is right only if you target your site for a widest audience possible. Otherwise YMMV.

image - Issues porting PHP/GD wrapper to Imagick - Stack Overflow

php image imagemagick gd imagick
Rectangle 27 1

You downloaded iOS binaries instead of sources. You need sources if you want to compile them by hand:

wget http://www.imagemagick.org/download/ImageMagick-6.9.3-0.tar.gz
tar xvzf ImageMagick-6.9.3-0.tar.gz
cd ImageMagick-6.9.3-0
./configure

Make sure that the output of the previous command shows this:

PNG               --with-png=yes        yes
make
sudo make install
sudo ldconfig /usr/local/lib

I am not so good with terminal commands when I am ssh'd in the local machine. Can you please add the necessary commands to write in your answer? Because I have been trying different stuff but got quiet lost. Thanks a lot in advance!

Thanks a lot! Just checked, it outputs PNG --with-png=yes yes when I use ./configure. But still the same error no decode delegate for this image format. What am I doing wrong? Please note that I did everything as you showed. I think PNG is there, but GIF is not. What is the way of adding it?

identify -list format
PNG* rw-   Portable Network Graphics (libpng 1.2.50)
GIF* rw+   CompuServe graphics interchange format

@senty What is this command saying: convert -list configure

php - Imagick - no decode delegate for this image format - Stack Overf...

php linux ubuntu imagemagick imagick
Rectangle 27 35

The DPI doesn't matter at all when dealing with images. Images are measured in pixels so this is what you need to adjust. You can safely disregard DPI as it has no sense in this context.

Scaling won't help you here - remember you are working with a pixel device, not vectors, so the canvas need to be already in the size you want to use for print etc. or you will have reduced quality due to interpolation when scaling it.

You need to pre-calulate your canvas size in pixels in relation to what size you want in the final stage.

Lets say you want to print a 15 x 10 cm image (or about 6 x 4 inches) @ 300DPI output. You then calculate the pixels:

Width : 10 cm * 300 / 2.54 = 1181 pixels
Height: 15 cm * 300 / 2.54 = 1772 pixels
Width : 4 in * 300 = 1200 pixels
Height: 6 in * 300 = 1800 pixels
26.45 cm * 300 DPI / 2.54 inches = 3124 pixels.

To display that canvas in a smaller area on screen you use CSS to display the element, for example -

<canvas width="3124" height="3124" style="width:600px;height:600px;"></canvas>

You can now draw to the canvas at its actual pixel position and it will show up scaled down on screen (but retain all information on the canvas itself). If you use mouse coordinates you just scale the mouse position proportionally (canvas pos = mouse coord * 3124px / 600px).

For zooming etc it becomes a tad more complicated, but the principle remains: the final size of your image must be that of the final result.

About DPI: if this image was 72 DPI or 300 DPI the numbers of pixels would be the exact same. The reason as already mentioned is that images are measured in pixels.

DPI is an arbitrary value when it comes to pixel devices (bitmaps, monitors, cameras etc.) and is only used for a DTP software to get a hint on dimension for final print which will use this information only to pre-scale the image in relation to the page you using to set the print with.

@K3N: I followed your suggestion, but I am stuck on a problem, the texts which are being placed are very small.please look at the fiddle jsfiddle.net/Q3TMA/1042

@Abhinav the font size must be scaled up in advance before drawn. You can use scale() for this or try with the font height directly. The latter is not always linear due to how font are made, but you should be able to get close.

But still the sized controls are appearing small, and what can be done for images?

@Abhinav I suggest you open this as a new question. My answer here only covers the underlying principle.

php - What is the best practice to export canvas with high quality ima...

php canvas html5-canvas fabricjs imagick
Rectangle 27 11

Instead of using "identify -format %n $file"(which can turn out to be extremely slow for complex or for mult-page PDFs) you should rather use the right tool for the job, pdfinfo:

exec("pdfinfo $file | grep Pages: | awk '{print $2}'")

Useful pointer, but I had some difficulty figuring out how to get pdfinfo in my systems. Finally: Debian/Ubuntu: sudo aptitude install poppler-utils; OSX: brew install poppler.

Count pages in PDF file using Imagemagick - PHP - Stack Overflow

php pdf imagemagick imagick
Rectangle 27 10

You could use imagemagick through exec() or similar, the shell arguments are much less verbose than the PHP extension.

$pdf_file = escapeshellarg( "mysafepdf.pdf" );
$jpg_file = escapeshellarg( "output.jpg" );

$result = 0;
exec( "convert -density 300 {$pdf_file} {$jpg_file}", null, $result );

// at this point $result should == 0 if the conversion was successful

It's the "-density" (which sets the DPI to read the source file as) option that specifically fixes your problem.

Also imagemagick by default uses a -quality setting of 92 for JPEG writing in most cases - so you probably don't need to explicitly declare it.

PDF to JPG conversion using PHP - Stack Overflow

php pdf imagemagick imagick
Rectangle 27 10

You could use imagemagick through exec() or similar, the shell arguments are much less verbose than the PHP extension.

$pdf_file = escapeshellarg( "mysafepdf.pdf" );
$jpg_file = escapeshellarg( "output.jpg" );

$result = 0;
exec( "convert -density 300 {$pdf_file} {$jpg_file}", null, $result );

// at this point $result should == 0 if the conversion was successful

It's the "-density" (which sets the DPI to read the source file as) option that specifically fixes your problem.

Also imagemagick by default uses a -quality setting of 92 for JPEG writing in most cases - so you probably don't need to explicitly declare it.

PDF to JPG conversion using PHP - Stack Overflow

php pdf imagemagick imagick
Rectangle 27 8

In order to get the correct parameters for these functions, you may try the following:

$fp_pdf = fopen($pdf, 'rb');
$params=array();

    $img = new imagick(); 
    $img->readImageFile($fp_pdf);
    /*my modification: */$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
    /*my modification: */$params=$img->identifyImage();
    $img->setImageFormat( "jpg" );
    $img->setImageCompression(imagick::COMPRESSION_JPEG); 
    $img->setImageCompressionQuality(90); 
    /*my modification: */$img->setPage($params['geometry']['width'], $params['geometry']['height'], 0, 0)
    /*my modification: */$img->setResolution($params['resolution']['x'], $params['resolution']['y']);
    $img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
    $data = $img->getImageBlob();

If you find that some others attributes should be set, then let me show you the information that $params is holding. It may proof useful for you:

$params=array(
    [imageName],
    [format], 
    [geometry] => Array
        (
            [width]
            [height] 
        )
    [type], 
    [colorSpace], 
    [resolution],
        (
            [x] 
            [y]
        )

    [units],
    [fileSize],
    [compression],
    [signature],

To be honest, I'm not completely sure if this will work. Is just a try in order to help you. I sincerely hope it does.

Thanks for answer, but how i can imagine what is value i should pass in these functions ? PDF has paper A4 size, how do i know how mucn in px it should to make the same dimension on paper ? or for printing purpose only DPI value will be used ?

it does not help. This is info about pdf o7.no/uAMcLa. The main strange thing is, i made this convertation using shell_exec("convert -density 300 -units pixelsperinch +matte in out"). and result image become in expected dimensions.

PDF to JPG conversion using PHP - Stack Overflow

php pdf imagemagick imagick