minimagick

How to decode base64 image file with mini_magick in Rails?

我们两清 提交于 2019-12-22 08:03:50
问题 In our Rails 4 app, the image is uploaded to server in a base64 string: uploaded_io = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2....." We would like to to retrieve the content type, size and so on and save the file as image file on file system. There is a gem 'mini_magick' in our app. Is there a way to process base64 image string with mini_magick ? 回答1: Yes, there is a way to do that. Strip metadata "data:image/jpeg;base64," from your input string and then decode it with Base64

Rails - WIndows 7 carrierwave, minimagick resize not working

回眸只為那壹抹淺笑 提交于 2019-12-14 04:12:34
问题 I tried to set up for uploading photos with my rails app. However, the carrierwave uploader does not resize the photos being uploaded. When I do not call the resize_to_fill function, the photos are uploaded perfectly. Any advice? When a photo is submitted with resize_to_fill, the error 'failed to be processed' is returned. How can i fix it? I guess I need to 'require' 'carrierwave/processing/mini_magick' for calling resize_to_fill, but i don't know where to put this file. gemfile "carrierwave

Carrierwave converting PDF to JPG (MiniMagick)

寵の児 提交于 2019-12-14 04:01:56
问题 I have a problem creating JPG thumbnails for PDF files. I'm using Carrierwave. Imagemagick is properly installed. There are no problems creating thumbnails of PNG, JPG or GIF files. Here is the code I use version :thumb, :if => :image? do storage :file begin process :convert => 'jpg' # this should do the trick but doesn't process :resize_to_fill => [160,160] process :quality => 95 process :set_content_type process :set_thumb_attr => true def full_filename (for_file = model.file.file) "#{model

Errors are displayed twice in rails

こ雲淡風輕ζ 提交于 2019-12-13 17:00:51
问题 I am using carrierwave to upload the profile picture in user model. If the user tries to upload any file that is not an image, then an error must be raised. However the error is displayed twice on the screen. Please help code for user model class User < ActiveRecord::Base include CarrierWave::MiniMagick validates :email, :presence =>true, :uniqueness => {case_sensitive: false}, :format => { :with=> /([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]

Corp image with ruby

微笑、不失礼 提交于 2019-12-13 08:51:03
问题 I try to corp an image how you can see in my last line of code i trigger: p.corp!(0,0,p.width,black_last).save('bearbeitet.png') But somehow i get this error: bild.rb:29:in `<main>': undefined method `corp!' for #<ChunkyPNG::Canvas:0x24f34 50> (NoMethodError) Why? The docu for corp: http://rdoc.info/gems/chunky_png/ChunkyPNG/Canvas/Operations#crop-instance_method My whole code: Thanks! require 'mini_magick' require 'chunky_png' i = MiniMagick::Image.open("a.jpg") i.format('png') p = ChunkyPNG

Combining options in MiniMagick

荒凉一梦 提交于 2019-12-13 08:47:30
问题 I'm trying out MiniMagick for some image manipulation but I'm having trouble combining commands. I want to use the trim command with a fuzz factor. Calling image.fuzz "30%" image.trim works perfectly. But my understanding is that the fuzz factor will continue to be set for all future commands, which I don't want. Instead I've tried image.combine_options do |c| c.fuzz "30%" c.trim end but unfortunately this doesn't seem to do anything (unless I set the fuzz factor to 100% in which case it

Checking Minimagick height freezes console

倖福魔咒の 提交于 2019-12-13 07:43:03
问题 I'm using Rails with MiniMagick and have this obj that I've uploaded through file_field and MiniMagick::Image.read(image.read) : => #<MiniMagick::Image:0x007feb61ac7048 @info=#<MiniMagick::Image::Info:0x007feb61ac6ff8 @info={}, @path="/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-1kxoub0">, @path="/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-1kxoub0", @tempfile=#<File:/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini

MiniMagick not working in production

妖精的绣舞 提交于 2019-12-13 04:19:34
问题 I am using MiniMagick gem to crop images and then saving them with mongoid paperclip. Everything seems to be working perfectly in development but in production I am getting the error "ActionView::Template::Error (uninitialized constant Model Name ::MiniMagick)". these are the lines giving the error inside the model: def profile_geometry img = MiniMagick::Image.open(avatar.path) @geometry = {:width => img[:width], :height => img[:height] } end Any help would be hugely appreciated. EDIT:

Carrierwave +repage option not working

旧城冷巷雨未停 提交于 2019-12-11 19:51:32
问题 In my Carrerwave custom process method, I'm attempting to use the +repage option. Documentation was kind of hard to come across, but I found that I needed to run img.repage.+ . However that didn't work out as it didn't even try to convert the option to +, but kept it at -repage and threw an error illustrating as much. Then I found a page which illustrated to write it out as: img.push '+repage' img.+ img.repage It used a different example (not using repage, but using '+profile' with two

Translate ImageMagick CLI into MiniMagick gem

十年热恋 提交于 2019-12-11 15:16:16
问题 I finally figured out how to convert a CMYK color into an RGB value using color profiles and ImageMagick (Converting colors (not images) with ImageMagick). Now I'm struggling to incorporate the following command into a Rails app using MiniMagick : magick convert xc:"cmyk(255,0,0,0)" -profile USWebCoatedSWOP.icc -profile sRGB_IEC61966-2-1_black_scaled.icc -format "%[pixel:u.p{0,0}]\n" info: Which should return something like this: srgb(0%,68.0964%,93.8003%) Any ideas? I would be happy to just