Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background image is lost when saving as .svg #53

Open
Lonami opened this issue Apr 9, 2017 · 5 comments
Open

Background image is lost when saving as .svg #53

Lonami opened this issue Apr 9, 2017 · 5 comments
Labels

Comments

@Lonami
Copy link
Contributor

Lonami commented Apr 9, 2017

It's possible to embed images on .svg files, as the following "example" shows:

<image
    y="0"
    x="0"
    xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA…"
    preserveAspectRatio="none"
    height="568"
    width="512" />

This is what inkscape saves.

@tibbi tibbi added the bug label Apr 9, 2017
@Lonami
Copy link
Contributor Author

Lonami commented Apr 9, 2017

And encoding as base64 can be done as follows (courtesy of Stack Overflow):

// Get the bytes array
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();  
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();

// Encode the bytes into base64
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);

@cbertelli
Copy link

I would prefer the linked object without the Base64 string.
Il could at least help making the SVG the same size as the background image if there are no drawings outside it (meaning that the user is annotating the photo).
By the way, I would store the annotations in a database if allowed.

@Lonami
Copy link
Contributor Author

Lonami commented Feb 9, 2020

I would prefer the linked object without the Base64 string

If we use an absolute path, I think the .svg would be pretty useless once you move it out from the phone/tablet. If we use a relative path (or maybe just the name), then we need to store this mapping somewhere. I think it would be a tad bit trickier.

@cbertelli
Copy link

I would prefer something like the linked object in Inkscape:

    <image
       sodipodi:relref="IMG_20160708_231027.jpg"
       xlink:href="IMG_20160708_231027.jpg"
       y="462.69064"
       x="7.4576993"
       id="image1419"
       preserveAspectRatio="none"
       height="607.5"
       width="1080"
       style="image-rendering:auto" />

Anyway the problem is retaining the image position o using a canvas the same size as the picture if there are no drawings outside.

@cbertelli
Copy link

cbertelli commented Feb 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants