0

I am having issues with ImageMagick. I downloaded ImageMagick through Homebrew and for some reason the captcha appears blacked out.

This is what I am getting:

enter image description here

Here is the ImageMagick version I am using:

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

Also this is what I am receiving in the console:

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"]]

I can also provide any other information that is requested.

-Thank you!

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • 1
    You need to add the code that generates the capture. I would guess the transparency behind the letters is not working. I am not sure but I think V7 treats some transparency differently to V6 and the code may need changing. Or change the letter background to white. – Bonzo Apr 26 '17 at 06:45
  • Hey @Bonzo what do you mean by `You need to add the code that generates the capture` How would I do that? -Thank you. – Hamel Desai Apr 26 '17 at 12:38
  • You must have witten some imagemagick code somewhere or are you using some code you have found on the web? Depending how you installed Imagemagick you may need to use magick rather than convert in the code and as I said you may need to alter the code for V7 transparency. The capture is probably black as the letter background is not transparent. – Bonzo Apr 26 '17 at 12:45
  • I think this is generated by [SimpleCaptcha](https://github.com/galetahub/simple-captcha/blob/2602bf19a63df25929960b5a7721a9d265281ec1/lib/simple_captcha/image.rb). Default settings would generate the following command: `convert -fill darkblue -background white -size 100x28 -wave 2x92 -gravity Center -pointsize 22 -implode 0.2 label:12345 temp.jpg` – emcconville Apr 26 '17 at 14:09
  • The code from @emcconville works for me with convert but fails using magick on a windows PC. I tried moving some of the options around without success. – Bonzo Apr 26 '17 at 15:52

1 Answers1

1

As I said in my comments the code posted by @emcconville worked for me on a windows PC.

It failed when using magick and as I suspected magick ( V7 ) needs the operators in a different order as it is stricter than V6. So this worked again for me on my PC:

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

I would guess SimpleCapture is not V7 compatible; have you a V6 version you could try? I am using a V7 version but it also has a legacy V6 version built in but might not work on a mac?

Bonzo
  • 5,169
  • 1
  • 19
  • 27
  • Hey, so I have a feeling I am not doing this correctly so I run the code `magick -size 100x28 -background white -gravity Center -fill darkblue -pointsize 22 label:12345 -wave 2x92 -implode 0.2 "E:\Pictures\temp.jpg"` and the image I get is `12345` – Hamel Desai Apr 26 '17 at 18:59
  • Is it a distorted 12345? – Bonzo Apr 26 '17 at 19:16
  • 1
    I am afraid that is all the code @emcconville posted does. But I would say that indicates that SimpleCapture does not support V7. To confirm I would suggest removing your V7 version of Imagemagick and try a V6 version. If you are building a website you could try the SimpleCapture code there and if it woks ignore it on your mac and test it online instead. – Bonzo Apr 26 '17 at 19:29
  • Yep. The `12345` is just FPO (for placement only). The library would generate random characters. – emcconville Apr 26 '17 at 19:41
  • See [this answer](http://stackoverflow.com/a/41801911/438117) for installing ImageMagick 6 with homebrew. – emcconville Apr 26 '17 at 19:46
  • So @emcconville and @Bonzo I installed `imagemagick version 6.9.8-4` through homebrew, but now I am getting this http://imgur.com/TTmqZH1. -Thank you. – Hamel Desai Apr 26 '17 at 20:54
  • Sorry I do not know where to go next. It looks like the last image you posted has a missing capture image. It could be a problem with the code or possibly a permission problem. – Bonzo Apr 27 '17 at 16:48