-
Notifications
You must be signed in to change notification settings - Fork 62
Processor [:vips] not reading base64 #280
-
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 ~
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 7 replies
-
Hi @jessebarnes, this looks like a ImageProcessing (I think?) error. I'd open an issue there.
Beta Was this translation helpful? Give feedback.
All reactions
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
-
Sorry, no idea, you are not using ruby-vips, you are using the ImageProcessing gem (I think). You'd need to ask there.
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.