Feature #2047

Add SVG support, like images

Added by Pierre Bertet about 9 years ago. Updated 10 months ago.

Status:NewStart date:2008-10-18
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Attachments
Target version:Candidate for next major release
Resolution:

Description

It would be great if we could :

  • Show attached SVG (no direct download)
  • Insert an SVG file in wiki pages, with a syntax near from "!!"

Syntax proposal :

Wiki : °link/to/svg_file.svg°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

ananas.svg - Demo: this file will not be displayed, but directly downloaded (34.7 KB) Pierre Bertet, 2008-10-18 01:15

History

#1 Updated by Pierre Bertet about 9 years ago

Update (I forgot the dimensions) :
Wiki : °link/to/svg_file.svg(100x100)°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

#2 Updated by Oleg Lozinskij over 8 years ago

Pierre Bertet wrote:

Update (I forgot the dimensions) :
Wiki : °link/to/svg_file.svg(100x100)°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

Exactly what I was looking for :)

It is already available?

#3 Updated by Pierre Bertet over 7 years ago

Any news?

#4 Updated by Karel Pičman about 5 years ago

+1

#5 Updated by Karel Pičman about 5 years ago

You can display SVG image if you put full URL of the image:

!http://www.redmine.org/attachments/download/1042/ananas.svg!

#6 Updated by Jun NAITOH about 5 years ago

+1

patch for trunk.

  • Show attached SVG (no direct download)
    Index: app/models/attachment.rb
    ===================================================================
    --- app/models/attachment.rb    (revision 10173)
    +++ app/models/attachment.rb    (working copy)
    @@ -162,7 +162,7 @@
       end
    
       def image?
    -    !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i)
    +    !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|svg)$/i)
       end
    
       def thumbnailable?
    
  • Insert attached SVG file in wiki pages, with a syntax near from "!!"
    Index: app/helpers/application_helper.rb
    ===================================================================
    --- app/helpers/application_helper.rb    (revision 10173)
    +++ app/helpers/application_helper.rb    (working copy)
    @@ -572,7 +572,7 @@
         # when using an image link, try to use an attachment, if possible
         if options[:attachments] || (obj && obj.respond_to?(:attachments))
           attachments = options[:attachments] || obj.attachments
    -      text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
    +      text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|svg))"(\s+alt="([^"]*)")?/i) do |m|
             filename, ext, alt, alttext = $1.downcase, $2, $3, $4
             # search for the picture in attachments
             if found = Attachment.latest_attach(attachments, filename)
    

#7 Updated by YT Wu about 5 years ago

can this patch support the export to PDF function ( with image in the PDF file ) ?

#8 Updated by Jun NAITOH about 5 years ago

YT Wu wrote:

can this patch support the export to PDF function ( with image in the PDF file ) ?

No.
Because, RFPDF library is not supporting SVG file.

#9 Updated by Evgeny Seliverstov over 4 years ago

Jun NAITOH wrote:

patch for trunk.

Is there a chance to get this small patch in trunk? Manual patches to redmine files is not a best solution.
I think it can't break anything except a missed image in PDF.

#10 Updated by Mischa The Evil over 4 years ago

  • Target version set to Candidate for next major release

The patches in note-6 from Jun NAITOH seem feasible.

#11 Updated by Gabriel Mazetto over 4 years ago

RFPDF is obsolete, even the author is migrating to Prawn: https://github.com/edwinmoss/rfpdf We should consider migrating too.

#12 Updated by Toshi MARUYAMA over 4 years ago

Gabriel Mazetto wrote:

RFPDF is obsolete, even the author is migrating to Prawn: https://github.com/edwinmoss/rfpdf We should consider migrating too.

RFPDF is maintained by Jun NAITOH.
https://github.com/naitoh/rfpdf

#13 Updated by Adrien Crivelli about 4 years ago

We often use SVG images and would be glad to see them supported with the same syntax as any other images. I am in favor of implementing patch suggested in note 6.

#14 Updated by Paulo Neves over 3 years ago

This is really easy to implement. Is there any needed step still? Do the maintainers need a test unit for this?

#15 Updated by yp xiao over 2 years ago

This is a really useful feature!

#16 Updated by Go MAEDA about 2 years ago

I tried Jun NAITOH's patch pasted on #2047#note-6 but thumbnails for SVG images are not properly generated on my environment.

  • Redmine 3.1.1.devel.14638
  • ImageMagick 6.8.9-8
  • Mac OS X 10.9.5

error messages in development.log:

Creating thumbnail failed (pid 16631 exit 1):
Command: 'convert' '/path/to/redmine/files/2015/10/151004112923_ananas.svg' -thumbnail '100x100>' '/path/to/redmine/tmp/thumbnails/40_6f1215c37c5a7abc38cc60463fac05df_100.thumb'

command line:

$ convert ananas.svg -thumbnail 100x100
convert: delegate failed `"rsvg-convert" -o "%o" "%i"' @ error/delegate.c/InvokeDelegate/1153.
convert: unable to open image `/var/tmp/magick-16839ei4QFzFms7K4': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: unable to open file `/var/tmp/magick-16839ei4QFzFms7K4': No such file or directory @ error/constitute.c/ReadImage/540.
convert: missing an image filename `100x100' @ error/convert.c/ConvertImageCommand/3184.

#17 Updated by Silvio Knizek 11 months ago

Karel Pičman wrote:

You can display SVG image if you put full URL of the image:

[...]

The problem with this is that you can't click on any hyperlinks embedded into the SVG. So for SVG a specific case would be more appropriate.

#18 Updated by Zer Guz 11 months ago

+1

#19 Updated by Go MAEDA 10 months ago

Current implementation of Redmine::Thumbnail.generate method creates thumbnail images in same format with original image. But ImageMagick convert command cannot make thumbnails in SVG format. The following is a result of convert ananas.svg -thumbnail 100x100 thumbnail.svg.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="100" height="100">
<g style="</svg>

Maybe we have to generate all thumbnails in PNG or JPEG format to support SVG images.

Also available in: Atom PDF