error on Magick

10 views
Skip to first unread message

a manhood

unread,
Apr 24, 2013, 6:00:31 AM4/24/13
to codea...@googlegroups.com, hk...@googlegroups.com
Dear all,

I can not convert the pdf to jpgs by Magick (ruby on rails)

Magick::Image::read('public/uploads/ebook/pdf/5/facebook-marketing-update-spring-2011.pdf').each_with_index { |img, i|
    img.resize_to_fit!(800, 1000)
  img.write("public/uploads/ebook/pdf/5/facebook-marketing-update-spring-2011.pdf-#{i}.jpg") {
  self.quality = 80
  }
 }

The above codes work well.

However, when i change to below code, it shows no decode delegate for this image format `public/#{@ebook.pdf.to_s}' @ error/constitute.c/ReadImage/532

 def create
    @ebook = Ebook.new(params[:ebook])
    respond_to do |format|
      if @ebook.save
Magick::Image::read('public/#{@ebook.pdf.to_s}').each_with_index { |img, i|
 img.resize_to_fit!(800, 1000)
 bookpage = Bookpage.new
 bookpage.ebook_id = @ebook.id
 bookpage.name = "#{@ebook.pdf}-#{i}.jpg"
 bookpage.page_no = i + 1
 bookpage.save
 img.write("public/#{@ebook.pdf}-#{i}.jpg") {
   self.quality = 120
 }
}
        format.html { redirect_to @ebook, notice: 'Ebook was successfully created.' }
        format.json { render json: @ebook, status: :created, location: @ebook }
      else
        format.html { render action: "new" }
        format.json { render json: @ebook.errors, status: :unprocessable_entity }
      end
    end
  end

the @ebook.pdf = uploads/ebook/pdf/5/facebook-marketing-update-spring-2011.pdf

Could you please teach me how to solve it ? i have on ideas what's error. Some articles showed me to install something on imagemagick.

Thanks,
Alex





Matthew Rudy Jacobs

unread,
Apr 24, 2013, 6:18:42 AM4/24/13
to hk...@googlegroups.com

Take a look at the error.
The answer is pretty clear.

Your variable is not being interpolated.

Take a look at the rules for ruby strings and when they will or will not interpolate variables.

--
You received this message because you are subscribed to the Google Groups "Hong Kong Ruby on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hkror+un...@googlegroups.com.
To post to this group, send email to hk...@googlegroups.com.
Visit this group at http://groups.google.com/group/hkror?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages