我在Imagick中找到了两种设置图像压缩质量的方法
A)setImageCompressionQuality
B)setCompressionQuality
所以我想知道哪一个是最好的以及为什么在以下条件
我读到bundle exec rake db:drop RAILS_ENV=test
bundle exec rake db:create RAILS_ENV=test
bundle exec rake db:schema:load RAILS_ENV=test
方法仅适用于新图像(?)
我正在尝试压缩文件jpeg / png
setCompressionQuality
答案 0 :(得分:2)
方法setImageCompressionQuality
设置当前图像的压缩质量。此方法是MagickWand
的{{1}}函数的包装器。 Source code是:
MagickSetImageCompressionQuality
方法WandExport MagickBooleanType MagickSetImageCompressionQuality(MagickWand *wand,
const size_t quality)
{
assert(wand != (MagickWand *) NULL);
assert(wand->signature == MagickWandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->images == (Image *) NULL)
ThrowWandException(WandError,"ContainsNoImages",wand->name);
//This line sets the quality for the instance 'images'
wand->images->quality=quality;
return(MagickTrue);
}
设置整个对象的压缩质量。此方法是setCompressionQuality
的{{1}}函数的包装器。 Source code是:
MagickWand
MagickSetCompressionQuality
结构包含WandExport MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
const size_t quality)
{
assert(wand != (MagickWand *) NULL);
assert(wand->signature == MagickWandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
//This line sets quality for the image_info struct instance.
wand->image_info->quality=quality;
return(MagickTrue);
}
和MagickWand
结构的实例,source:
Image
两个Image
and ImageInfo
结构都包含ImageInfo
个数据成员。所以对于你的例子struct _MagickWand
{
...
Image
*images; /* The images in this wand - also the current image */
ImageInfo
*image_info; /* Global settings used for images in Wand */
...
};
完全没问题。