Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Processor [:vips] not reading base64 #280

Unanswered
jessebarnes asked this question in Q&A
Discussion options

Have a Posts.rb with has_attached_file:

 has_attached_file :gif, 
 styles: {
 original: {},
 large: '512x512>', format: 'gif',
 square: '256x256>', format: 'gif',
 thumbnail: '70x70>', animated: false, format: 'gif' 
 },
 :convert_options => {
 :cmyk_original => lambda { |file| [{
 cmd: "copy",
 args: ["n: -1"]
 }].to_json }
 },
 processors: [:vips]
 validates_attachment :gif, content_type: { content_type: 'image/gif' }, if: Proc.new { |a| a.gif? }
 validates_with AttachmentSizeValidator, attributes: :gif,
 less_than: 9.megabytes,
 message: 'Gif exceeds 9mb upload size limit'

Postman API Body:

"content": "Hi Mom",
"gif": "data:image/gif;base64,R0lGODlhAALXAPcAAAECBAsEAwAGC.."

With Processor [:vips] we received :

{
 "error": true,
 "message": "Gif Paperclip::Errors::NotIdentifiedByImageMagickError, Gif has contents that are not what they are reported to be"
}

When the processor is taken out, we do not have any issues. Not sure what is happening... any suggestions? Is my model correct? Thanks ~

You must be logged in to vote

Replies: 1 comment 7 replies

Comment options

Hi @jessebarnes, this looks like a ImageProcessing (I think?) error. I'd open an issue there.

You must be logged in to vote
7 replies
Comment options

trying to pass in Post model w/convert_options on has_attached_file :gif in ruby on rails

when I pass in "copy" in cmd and "n:-1" as args, I get this error:
"unable to call copy: you supplied 2 arguments, but operation needs 1"

current code:

 convert_options: {
 :large => lambda { |file| [{
 cmd: "copy",
 args: "[n: -1]"
 }].to_json }
 },

error: unable to call copy: you supplied 2 arguments, but operation needs 1

Thanks so much @jcupitt, am I passing this in incorrectly?

Comment options

Sorry, no idea, you are not using ruby-vips, you are using the ImageProcessing gem (I think). You'd need to ask there.

Comment options

No, I am using Ruby-Vips. I am using your gem with Image Magick and kt-paper-clip. The above usage is from your documentation.

How would you incorporate your gem with this argument in a model like the example usage shows in your readme?

Please, help~

Gemfile:
ruby-vips (2.0.17)
ffi (~> 1.9)
...
paperclip-vips!
remote: https://github.com/tsu-social/paperclip-vips.git
...
here is the github link -> https://github.com/realhub/paperclip-vips

Is this the wrong usage? thank you so much

Comment options

Yes, but you are not using ruby-vips directly, you're using it via some other API I don't know, perhaps the ImageProcessing gem, or maybe paperclip.

You need to ask the people who made the gem you are using.

Comment options

Looks like you need to ask paperclip-vips, that's the gem you are using.

Though I don't know if it's the best solution -- in rails6, ActiveRecord uses ImageProcessing for image handling, and that has a vips backend. I think I would go that route instead.

Have a look at eg.:

https://bloggie.io/@kinopyo/upgrade-guide-active-storage-in-rails-6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /