minimagick

CarrierWave RMagick - How do I cause manipulate! to be called?

﹥>﹥吖頭↗ 提交于 2019-12-11 04:38:52
问题 Greetings wise people, I am trying to use MiniMagick with CarrierWave in Rails 3 to resize and store an image according to the instructions here: http://carrierwave.rubyforge.org/rdoc/classes/CarrierWave/MiniMagick.html I can upload images with no processing. The image is uploaded and I can see it in the directory and the application. But when I try to perform processing on the image, the block inside manipulate! method is never being called. Do you know how I can solve this? I have the

Convert a pdf to png using mini_magick in Ruby on Rails

痞子三分冷 提交于 2019-12-11 03:42:34
问题 Background I retrieved a pdf in binary form from an API call: base_64_binary_data = @response_label[:generate_label_response][:response_shipments][:response_shipment][:labels][:label][:content] @pdf_file = File.open('label.pdf', 'wb') do |file| content = Base64.decode64 base_64_binary_data file << content end The above code results in a file that I can look up and is the crystal clear image I need. Issue I need to place this image inside a view in order to function as a label on an invoice.

How to convert a PDF into an array of images, with Carrierwave and MiniMagick (Ruby on Rails)

梦想的初衷 提交于 2019-12-09 22:40:26
问题 I'm converting uploaded PDFs into images, with one image per page. I have figured out how to generate the images using MiniMagick::Tool::Convert , but I don't know how to write the version block for the Uploader, so that I can access an array of image URLs. Here's my uploader so far: class DocumentUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick storage :file # storage :fog def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end version :jpg

Unable to crop image using mini_magick

不羁的心 提交于 2019-12-08 16:56:54
问题 I am using mini_magick as the interface of utilizing ImageMagick to manipulate some image. The resize works fine . But when I want to crop some image: img = MiniMagick::Image.open(url) img.crop('200x800!') It constantly prompts No such file No such file or directory - /var/folders/c4/mqlwdx_d3kj6hqcnvbjr9mn80000gn/T/mini_magick20120504-11111-16kayc1.png 回答1: Ah, I was searching with wrong key phrase I guess. The right answer come to me when I search minimagick instead of mini_magick .

Unicode characters render with Rmagick but not with Minimagick

£可爱£侵袭症+ 提交于 2019-12-08 11:17:27
问题 Due to the performance advantages of Minimagick of Rmagick (and the fact the Rmagik is on the way out) I would like to be able to able to perform the following operation in Minimagick. By default it seems that Minimagick does not handle unicode character well, but Rmagick has no roblem at all (this code works fine): def getimage bg = Magick::ImageList.new("#{Rails.root}/app/assets/images/template.png") text = Magick::Draw.new text.encoding = "Unicode" text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")

MiniMagick Image.create method giving an ArgumentError

℡╲_俬逩灬. 提交于 2019-12-08 05:45:32
问题 I'm creating a collage of thumbnails using Ruby 1.9.3. The thumbnails are being loaded as follows: image1 = MiniMagick::Image.open("1.jpg") image2 = MiniMagick::Image.open("2.jpg") image2.rotate "-45>" image3 = MiniMagick::Image.open("3.jpg") image3.rotate "45>" I've never used ImageMagick or MiniMagick before and I've got the code for compositing images from the minimagick GitHub page. collage = MiniMagick::Image.create "jpg", false do |c| c.size "1024x768" c.canvas "white" end collage =

Get image dimensions using Refile

有些话、适合烂在心里 提交于 2019-12-06 01:42:58
问题 Using the Refile gem to handle file uploading in Rails, what is the best way to determine image height and width during / after it has been uploaded? There is no built in support for this AFAIK, and I can't figure out how to do it using MiniMagick. 回答1: @russellb's comment almost got me there, but wasn't quite correct. If you have a Refile::File called @file, you need to: fileIO = @file.to_io.to_io mm = MiniMagick::Image.open(fileIO) mm.width # image width mm.height # image height Yes, that's

How to decode base64 image file with mini_magick in Rails?

本小妞迷上赌 提交于 2019-12-05 11:29:28
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 ? Yes, there is a way to do that. Strip metadata "data:image/jpeg;base64," from your input string and then decode it with Base64.decode64 method. You'll get binary blob. Feed that blob to MiniMagick::Image.read . ImageMagick is smart enough

Carrierwave: Scale image if the size is larger than (conditionally create versions)

感情迁移 提交于 2019-12-05 02:13:34
问题 Is possible with carrierwave create a version (for example thumb) only if the image is larger than the size of the version?? Example: version :thumb, :if => :is_thumbnable? do process :resize_to_fit => [32,nil] end protected def is_thumbnable?(file) image ||= MiniMagick::Image.open(file.path) if image.nil? if image['width'] >= 32 || image['height'] >= 32 true else false end else false end end 回答1: I defined method in which if image exceed given width then manipulate it to your size the 32

Retrieving the hex code of the color of a given pixel

被刻印的时光 ゝ 提交于 2019-12-04 09:59:04
问题 I have used resize_to_fill down to a [1,1] size thus reducing the image to a single pixel containing what is basically the average color of the entire image (provided the image does not have a huge disparity between height and width, of course). Now I'm attempting to retrieve the color of this single pixel in hex format. From the terminal window I am able to run the convert command like this: convert image.png txt: # ImageMagick pixel enumeration: 1,1,255,rgb 0,0: (154,135,116) #9A8774 rgb