Nick Brutyn
2005-Nov-03 14:12 UTC
RMagick and PDFWriter (Austin Ziegler): PNG alpha channel transparency is not su
hey,
i have created a png and i want to put that in the pdf,
the png creation works fine
def gen_image(filename)
dir = "public/images/geotags"
if ! FileTest.directory?(dir) then
Dir.mkdir(dir)
end
#canvas = Magick::Image.new(300, 300,
Magick::HatchFill.new(''white'',''lightcyan2''))
canvas = Magick::Image.new(240, 300)
canvas.opacity = 100
gc = Magick::Draw.new
# Draw ellipse
gc.stroke(''red'')
gc.stroke_width(3)
gc.fill_opacity(0)
gc.ellipse(120, 150, 80, 120, 0, 270)
# Draw endpoints
gc.stroke(''gray50'')
gc.stroke_width(1)
gc.circle(120, 150, 124, 150)
gc.circle(200, 150, 204, 150)
gc.circle(120, 30, 124, 30)
# Draw lines
gc.line(120, 150, 200, 150)
gc.line(120, 150, 120, 30)
# Annotate
gc.stroke(''transparent'')
gc.fill(''black'')
gc.text(130, 35, "End")
gc.text(188, 135, "Start")
gc.text(130, 95, "''Height=120''")
gc.text(55, 155, "''Width=80''")
gc.draw(canvas)
canvas.write(dir + "/" + filename)
end
the file is made and then i want to put it in the pdf like this
pdf.add_image_from_file("public/images/geotags/" + geotag_filename,
10,10 )
and i get this error
PNG alpha channel transparency is not supported; only palette transparency
is supported.
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/lib/pdf/writer/object/image.rb:261:in `initialize''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:580:in `new''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:580:in `add_image''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:549:in `add_image_from_file''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:286:in `print_tag''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:228:in `upto''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:228:in `print_tag''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:226:in `upto''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:226:in `print_tag''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:834:in
`send''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:834:in
`perform_action_without_filters''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/filters.rb:295:in
`perform_action_without_benchmark''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`measure''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/rescue.rb:82:in
`perform_action''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:365:in
`send''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:365:in
`process_without_session_management_support''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/session_management.rb:116:in
`process''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/dispatcher.rb:36:in
`dispatch''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:117:in
`handle_dispatch''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:83:in
`service''
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread''
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread''
c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each''
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:69:in
`dispatch''
script/server:49
#{RAILS_ROOT}/lib/pdf/writer/object/image.rb:261:in `initialize''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:580:in `new''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:580:in `add_image''
#{RAILS_ROOT}/lib/pdf/writer/graphics.rb:549:in `add_image_from_file''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:286:in `print_tag''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:228:in `upto''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:228:in `print_tag''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:226:in `upto''
#{RAILS_ROOT}/app/controllers/geotags_controller.rb:226:in `print_tag''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:834:in
`send''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:834:in
`perform_action_without_filters''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/filters.rb:295:in
`perform_action_without_benchmark''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`measure''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/rescue.rb:82:in
`perform_action''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:365:in
`send''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/base.rb:365:in
`process_without_session_management_support''
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/session_management.rb:116:in
`process''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/dispatcher.rb:36:in
`dispatch''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:117:in
`handle_dispatch''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:83:in
`service''
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread''
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread''
c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each''
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
c:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.2/lib/webrick_server.rb:69:in
`dispatch''
script/server:49