Rails3 Paperclip JCrop 进入循环

Posted

技术标签:

【中文标题】Rails3 Paperclip JCrop 进入循环【英文标题】:Rails3 Paperclip JCrop got into the loop 【发布时间】:2012-10-12 21:57:30 【问题描述】:

我有这个配置的典型设置,没什么特别的,像本教程中的:http://shareyourtechskills.blogspot.com/2011/01/jcrop-with-paper-clip-plugin.html

上传头像 - 有效,但是当我裁剪它时,进程卡在循环中,控制台中出现以下错误:

convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1cbz90w20121013-26133-1x1vcii20121013-26133-gjlod.png' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-fwu1jt.jpg' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-fwu1jt20121013-26133-1p255t220121013-26133-i8ny07.png' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-18wr3op.jpg' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-18wr3op20121013-26133-kp6o120121013-26133-1ut9jfy.png' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hjxk9x.jpg' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hjxk9x20121013-26133-rjrf8c20121013-26133-1eyrpxv.png' @ warning/transform.c/CropImage/572.
convert: GeometryDoesNotContainImage `/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-6h4lu.jpg' @ warning/transform.c/CropImage/572.

这个字符串大约有 500 个,然后我得到这个:

Started PUT "/users/1" for 127.0.0.1 at 2012-10-13 00:34:24 +0300
Processing by UsersController#update as HTML
  Parameters: "utf8"=>"✓", "authenticity_token"=>"ht7YiTS5yOqXFy0EWeFVLBfv5eZU0codQfR8DvlKHA=", "user"=>"crop_x"=>"223", "crop_y"=>"113", "crop_w"=>"145", "crop_h"=>"145", "commit"=>"Сохранить", "id"=>"1"
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", "1"]]
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1
   (0.0ms)  begin transaction
  User Exists (0.1ms)  SELECT 1 FROM "users" WHERE (LOWER("users"."email") = LOWER('example@example.com') AND "users"."id" != 1) LIMIT 1
Command :: identify -format %wx%h '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn.jpg[0]'
Command :: convert '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn.jpg[0]' -crop 145x145+223+113 -auto-orient -resize "145x" +repage '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v.png'
Command :: identify -format %wx%h '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe.png[0]'
Command :: identify -format %m '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe.png[0]'
Command :: identify -format %m '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe.png[0]'
Command :: convert '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe.png[0]' -crop 145x145+223+113 -auto-orient -resize "50x" +repage '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe20121013-26133-nkvpon'
Command :: file -b --mime '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-10hxtsn20121013-26133-1hplq8v20121013-26133-m37pe20121013-26133-nkvpon'
  CACHE (0.0ms)  SELECT 1 FROM "users" WHERE (LOWER("users"."email") = LOWER('inc@gnezdom.com') AND "users"."id" != 1) LIMIT 1
Command :: identify -format %wx%h '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut940.jpg[0]'
Command :: convert '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut940.jpg[0]' -crop 145x145+223+113 -auto-orient -resize "145x" +repage '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh.png'
Command :: identify -format %wx%h '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm09.png[0]'
Command :: identify -format %m '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm09.png[0]'
Command :: identify -format %m '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm09.png[0]'
Command :: convert '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm09.png[0]' -crop 145x145+223+113 -auto-orient -resize "50x" +repage '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm0920121013-26133-2rw91z'
Command :: file -b --mime '/var/folders/4p/v_37jqkj6810y7wsd8b7ly100000gn/T/38361898520121013-26133-1hut94020121013-26133-1k0w0qh20121013-26133-69pm0920121013-26133-2rw91z'

大约 500,然后我在浏览器中收到此错误:

SystemStackError in UsersController#update
stack level too deep

我很感兴趣,如果我只修剪一张,为什么会有这么多图片? 谢谢

【问题讨论】:

【参考方案1】:

大多数文章已经过时并且与当前版本的回形针和导轨不兼容,因此此配置需要重新组织,如评论中所述http://railscasts.com/episodes/182-cropping-images?view=comments#comment_160006 福纳说,那

    avatar.reprocess!

不能从模型调用,而是从这样的控制器调用:

    @user.avatar.reprocess!

ofcource,您需要验证它是否存在裁剪变量,如crop_x 和其他 附:谢谢,Fona 为您的评论。

【讨论】:

以上是关于Rails3 Paperclip JCrop 进入循环的主要内容,如果未能解决你的问题,请参考以下文章

尝试将 Jcrop 添加到 Paperclip 时无法批量分配虚拟属性

在 Paperclip 和 Rails 4 中将 Jcrop 坐标转换为 convert_options

Rails 3 和 Paperclip:“'identify' 命令无法识别”

Rails:使用 Jcrop 和回形针裁剪图像后出现重定向问题

如何直接从 ZipEntry(RubyZip、Paperclip、Rails 3)获取临时文件对象(内容类型正确,无需写入磁盘)?

Rails 3:乘客找不到捆绑程序安装的 git gem