PHP/Imagick/PDFlib翻转图像更改了位深度 [英] PHP/Imagick/PDFlib Flop Image Changes its Bit Depth
问题描述
我正在使用PNG图片,并尝试通过 php的imagick函数 进行翻转(镜像),
I am Having PNG Image And Trying To Flop (Mirror) by imagick function of php It Gets Flop Exactly But The
基本图片的格式为24位RGB
Base Image is In Format 24 Bit RGB
并在转换后到达
8位口感
8 Bit Pallated
.因此,主要问题在于,当我将两个图像都放置在我的 pdflib 页面中时,其中一个图像(转换后)显示为卷曲.... 原始图片 由Imagick制作的Flop(Mirror)后翻转输出,并在PDFlib中呈现->
. So the Main Problem is that when I use to place both images in my pdflib pages one of the image(converted) displays curly.... Original Image Output After Flop(Mirror) by Imagick and Rendered in PDFlib ->
我的代码很简单---->
My Code Is Simple ---->
$im = new Imagick($background_image);
$im->flopImage();
$im->writeimage($background_image."_flop.png");
修改日期=> 2013年10月29日 原始图片-> 大小 4.68 KB 位深度 32 翻转的图像-> 大小 7.99 KB 位深度 64 自动更改其属性 原始
Modified Date => 29 Oct 2013 Original Image -> Size 4.68 KB Bit Depth 32 Flopped Image -> Size 7.99 KB Bit Depth 64 Automatically Changes It's Properties ORIGINAL
已转换
Converted
推荐答案
Imagick正在使用最小的格式来保存图像.保存为这些格式都将产生相同的图像,但是具有以下大小:
Imagick is using the smallest format possible to save the image. Saving in these formats all produce the same image but have the sizes:
- 调色板-3.38kB
- RGBA 32位-6.14kB
- RGBA 64位-8.09kB
人们通常希望保存到尽可能小的文件.但是,您可以通过两种方式禁用它.
Saving to the smallest possible file is usually what people desire. However you can disable this in a couple of ways.
通过将png:format
选项设置为png00
,可以告诉Imagick使用与源图像相同的PNG格式.例如
You can tell Imagick to use the same PNG format as the source image by setting the png:format
option to png00
. e.g.
$imagick = new Imagick(realpath("../images/FlopOriginal.png"));
$imagick->flopImage();
$imagick->setOption('png:format', 'png00');
$imagick->writeImage("../images/Flop.png");
png:format
的完整选项是png8,png24,png32,png48,png64和png00.
The full options for png:format
are png8, png24, png32, png48, png64, and png00.
或者,您可以通过png:bit-depth
和png:color-type
明确设置保存PNG文件时使用的图像格式.
Alternatively you can explicitly set the image format to use when saving the PNG file, through the png:bit-depth
and png:color-type
e.g.
$imagick = new Imagick(realpath("../images/FlopOriginal.png"));
$imagick->flopImage();
$imagick->setOption('png:bit-depth', '8');
$imagick->setOption('png:color-type', 6);
$imagick->writeImage("../images/Flop.png");
颜色类型值来自libpng.h,并且为:
The color type values come from the libpng.h and are:
PNG_COLOR_TYPE_GRAY 0
PNG_COLOR_TYPE_RGB 2
PNG_COLOR_TYPE_PALETTE 3
PNG_COLOR_TYPE_GRAY_ALPHA 4
PNG_COLOR_TYPE_RGB_ALPHA 6
这两种方法均会产生类似于原始图像的RGBA 32位翻转图像.
Both those methods produce a flopped image that is RGBA 32bit like the original image.
这篇关于PHP/Imagick/PDFlib翻转图像更改了位深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!