【发布时间】:2017-04-26 01:05:39
【问题描述】:
我在使用 ImageMagick 时遇到问题。我通过 Homebrew 下载了 ImageMagick,由于某种原因,验证码显示为黑色。
这就是我得到的:
这是我正在使用的 ImageMagick 版本:
Hamels-MacBook-Air:gitreports HD$ magick -version
Version: ImageMagick 7.0.5-4 Q16 x86_64 2017-03-25 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
这也是我在控制台中收到的内容:
Started GET "/issue/hd719/Bloc-Jams" for ::1 at 2017-04-25 21:02:29 -0400
Processing by RepositoriesController#repository as HTML
Parameters: {"username"=>"hd719", "repositoryname"=>"Bloc-Jams"}
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."username" = ? LIMIT 1 [["username", "hd719"]]
Repository Load (0.3ms) SELECT "repositories".* FROM "repositories" INNER JOIN "repositories_users" ON "repositories"."id" = "repositories_users"."repository_id" WHERE "repositories_
users"."user_id" = ? AND "repositories"."name" = ? ORDER BY name ASC LIMIT 1 [["user_id", 1], ["name", "Bloc-Jams"]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."username" = ? LIMIT 1 [["username", "hd719"]]
CACHE (0.1ms) SELECT "repositories".* FROM "repositories" INNER JOIN "repositories_users" ON "repositories"."id" = "repositories_users"."repository_id" WHERE "repositories_users"."us
er_id" = ? AND "repositories"."name" = ? ORDER BY name ASC LIMIT 1 [["user_id", 1], ["name", "Bloc-Jams"]]
SimpleCaptcha::SimpleCaptchaData Load (0.2ms) SELECT "simple_captcha_data".* FROM "simple_captcha_data" WHERE "simple_captcha_data"."key" = ? ORDER BY "simple_captcha_data"."id" ASC
LIMIT 1 [["key", "438f5570aeba7ef4658ee2505ced9112e7221fa6"]]
(0.7ms) begin transaction
SQL (1.1ms) UPDATE "simple_captcha_data" SET "value" = ?, "updated_at" = ? WHERE "simple_captcha_data"."id" = ? [["value", "SJZSRC"], ["updated_at", "2017-04-26 01:02:29.640800"], ["
id", 1]]
(1.1ms) commit transaction
Rendered simple_captcha/_simple_captcha.erb (0.8ms)
Rendered repositories/repository.html.erb within layouts/application (42.4ms)
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
Completed 200 OK in 319ms (Views: 258.7ms | ActiveRecord: 4.9ms)
Started GET "/simple_captcha?code=438f5570aeba7ef4658ee2505ced9112e7221fa6&time=1493168549" for ::1 at 2017-04-25 21:02:30 -0400
SimpleCaptcha::SimpleCaptchaData Load (0.2ms) SELECT "simple_captcha_data".* FROM "simple_captcha_data" WHERE "simple_captcha_data"."key" = ? ORDER BY "simple_captcha_data"."id" ASC
LIMIT 1 [["key", "438f5570aeba7ef4658ee2505ced9112e7221fa6"]]
CACHE (0.0ms) SELECT "simple_captcha_data".* FROM "simple_captcha_data" WHERE "simple_captcha_data"."key" = ? ORDER BY "simple_captcha_data"."id" ASC LIMIT 1 [["key", "438f5570aeba
7ef4658ee2505ced9112e7221fa6"]]
我还可以提供要求的任何其他信息。
-谢谢!
【问题讨论】:
-
您需要添加生成捕获的代码。我猜这些字母背后的透明度是行不通的。我不确定,但我认为 V7 对某些透明度的处理与 V6 不同,代码可能需要更改。或者将字母背景更改为白色。
-
嘿@Bonzo 你说的
You need to add the code that generates the capture是什么意思@ 我该怎么做? -谢谢。 -
您一定在某处使用过一些 imagemagick 代码,或者您使用的是在网络上找到的一些代码?根据您安装 Imagemagick 的方式,您可能需要使用 magick 而不是在代码中进行转换,正如我所说,您可能需要更改 V7 透明度的代码。由于字母背景不透明,捕获可能是黑色的。
-
我认为这是由SimpleCaptcha 生成的。默认设置将生成以下命令:
convert -fill darkblue -background white -size 100x28 -wave 2x92 -gravity Center -pointsize 22 -implode 0.2 label:12345 temp.jpg -
@emcconville 的代码对我有用,但在 Windows PC 上使用 magick 失败。我尝试移动一些选项但没有成功。
标签: imagemagick