0

I have a list of images. All svgs are perfectly formatted in the list and I learned that there is some way to create a svg code that contains jpgs/pngs. So I'd like to create the code for a svg Image that centers a jpg/png file. Is that possible?

If that wasn't clear enough here is some Pseudo of what I'm trying to do:

<img class="imgSizing" src={svgCentersPng} />

  • Possible duplicate of [Does SVG support embedding of bitmap images?](http://stackoverflow.com/questions/6249664/does-svg-support-embedding-of-bitmap-images) – Patrick Jan 31 '17 at 08:17
  • Why not just use width and height to align them within the list? – Alex Magill Jan 31 '17 at 08:19
  • @Patrick no I guess the article you attached is a lot more general. I really asked for the way to center it. – user405981 Jan 31 '17 at 08:35
  • in that case, http://stackoverflow.com/questions/11105534/centering-image-with-svg – Patrick Jan 31 '17 at 18:18
  • @Patrick After I found out about the svg tag I found this one aswell. However, what I originally wanted was the src code to generate a svg file that has this img centered in it. – user405981 Feb 01 '17 at 00:39

1 Answers1

0

Since SVG is a text file, you could generate this (with a backend script like php) via parameters like "centerimage.svg?image=src/from/jpg". But why don't you just center the image using CSS?

With Flexbox this is just a piece of cake, see: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

campino2k
  • 1,618
  • 1
  • 14
  • 25