我正在使用Imagick组装一堆has_attached_file :avatar,
:styles => {
:thumb => "60x60>", :medium => "120x120>",
:original => "100%", small2: "65x65>", medium2: "144x144>"
},
:storage => :s3,
:s3_credentials => "#{::Rails.root.to_s}/config/aws.yml",
:s3_permissions => "public-read",
:url => ':s3_alias_url',
:path => "/slider/:attachment/:id_partition/:style/:filename",
:s3_host_alias => Settings.cloud_front_url,
:s3_protocol => :https,
:s3_headers => {'Expires' => (Time.now + 6060243012).httpdate},
default_url: "paperclip_default/slider/:style_missing.png"
。一切都很顺利,只是输出图像的颜色深度总是减少(输入为16,输出为1)。我在这个过程中使用content: [{
text: getOfferClosingParagraph(),
id: 'closingParagraph'
}, {
text: getSignature(),
id: 'signature'
}],
pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
//check if signature part is completely on the last page, add pagebreak if not
if (currentNode.id === 'signature' && (currentNode.pageNumbers.length != 1 || currentNode.pageNumbers[0] != currentNode.pages)) {
return true;
}
//check if last paragraph is entirely on a single page, add pagebreak if not
else if (currentNode.id === 'closingParagraph' && currentNode.pageNumbers.length != 1) {
return true;
}
return false;
},
,但看起来它根本没有效果。这是一个片段:
.tif
这给了我一个1位的图像。我尝试使用命令行执行此操作,它工作正常(setImageDepth()
)。
是否有人遇到类似的问题?
答案 0 :(得分:3)
在查看底层ImageMagick库的代码之后,显然这可行:
$imagick = new Imagick();
$imagick->newPseudoImage(200, 200, 'xc:white');
$imagick->setType(\Imagick::IMGTYPE_TRUECOLOR);
$imagick->setImageFormat('tiff');
$imagick->setImageDepth(16);
$imagick->writeImage("./output.tif");
system("identify output.tif");
输出是:
output.tif TIFF 200x200 200x200+0+0 16-bit sRGB 241KB 0.000u 0:00.000
没有。 ImageMagick文档中的任何地方都没有记录。呜。