ImageMagick导致验证码变黑

时间:2017-04-26 01:05:40

标签: imagemagick

我遇到了ImageMagick的问题。我通过Homebrew下载了ImageMagick,由于某种原因,验证码显示为黑屏。

这就是我得到的:

enter image description here

以下是我正在使用的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"]]

我还可以提供所要求的任何其他信息。

- 谢谢你!

1 个答案:

答案 0 :(得分:1)

正如我在评论中所说,@ emcconville发布的代码在Windows PC上为我工作。

使用magick时失败了,因为我怀疑magick(V7)需要操作符的顺序不同,因为它比V6更严格。所以这在我的电脑上再次为我工作:

magick -size 100x28 -background white -gravity Center -fill darkblue -pointsize 22  label:12345 -wave 2x92  -implode 0.2 "E:\Pictures\temp.jpg"

我猜想SimpleCapture不兼容V7;你有可能尝试的V6版本吗? 我使用的是V7版本,但它内置的是旧版V6版本但可能无法在Mac上运行?