在PHP中使用转换命令行工具设置图像分辨率 [英] set image resolution using convert command line tool in php

查看:112
本文介绍了在PHP中使用转换命令行工具设置图像分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用imagemagick将pdf文件转换为图像..但是,当文件转换为png图像时,其背景颜色会改变(灰色)...
将文件转换为jpg图像时,它的字体会受到影响,并且无法提供清晰的可见性.
请指导我如何将图像保留为与pdf文件相同的格式...

将pdf转换为jpg的代码是:

Hi,

I am using imagemagick to convert pdf file to images.. but when the file is converted into png images its background color changes (gray color)...
when file is converted into jpg image then it''s font is effected and does not give clear visibility..
Kindly guide me how to remain the images as the same format as pdf file...

the code to convert pdf to jpg is:

<?php

shell_exec("convert  annots.pdf i.jpg");

?>

推荐答案

请参阅我对该问题的评论.您更有可能需要重新采样图像.我认为您只是由于不知道正确的术语而未能在文档中找到所需的内容.现在您可以找到它了:
http://en.wikipedia.org/wiki/ImageMagick [ http://www.imagemagick.org/script/index.php [ http://www.imagemagick.org/script/command-line-processing.php [ ^ ],
http://www.imagemagick.org/script/command-line-options.php [ ^ ].

但是,我认为您根本不应该使用PHP shell_exec和命令行界面.在HTTP请求上启动外部进程始终是一个坏主意,这是不得已的选择.您可以使用PHP编程接口连接ImageMagic:
http://php.net/manual/en/book.imagick.php [ ^ ].

祝你好运,
—SA
Please see my comment to the question. More likely that you need to resample the image. I assume you failed to find what you need in the documentation just because you did not know correct term. Now you can find it out:
http://en.wikipedia.org/wiki/ImageMagick[^],
http://www.imagemagick.org/script/index.php[^],
http://www.imagemagick.org/script/command-line-processing.php[^],
http://www.imagemagick.org/script/command-line-options.php[^].

However, I don''t think you should use PHP shell_exec and the command line interface at all; this is always a bad idea to start an external process on HTTP request, a kind of a last resort. You can use PHP programming interface to ImageMagic:
http://php.net/manual/en/book.imagick.php[^].

Good luck,
—SA


这篇关于在PHP中使用转换命令行工具设置图像分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆