Answer the question
In order to leave comments, you need to log in
resize Carrierwave and ImageMagick not working?
Hi all. Who has a problem with resizing and using ImageMagick.
I stopped resizing the photo for 2 days.
Uploads files to public/uploads/tmp
Specifies both original and thumb. The photo is not resized, the thumb is equal to the original photo. And it is not loaded by store_dir. What is the problem?
new.html.erb
<%= form_for @image, html: { multipart: true } do |f| %>
<%= f.file_field :image %>
<%= f.submit %>
<% end %>
class ImagesController < ApplicationController
def new
@image = Image.new
end
def create
# render text: params
@image = Image.new(images_params)
if @image.save
redirect_to root_path
else
render 'new'
end
end
private
def images_params
params.require(:image).permit(:image)
end
end
class Image < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
class CreateImages < ActiveRecord::Migration
def change
create_table :images do |t|
t.string :image
t.timestamps null: false
end
end
end
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fit => [50, 50]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'carrierwave'
gem 'mini_magick'
Answer the question
In order to leave comments, you need to log in
Maybe the package was updated unsuccessfully?
Seen this blog.ericlamb.net/2008/11/fix-for-convert-no-decod ... www.imagemagick.org/discourse-server/viewtopic.php... ?
What if you manually do conversions from the console?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question