prikhi/pencil

Can't resize objects imported from Openclipart

prikhi opened this issue · 6 comments

From ariji...@gmail.com on June 23, 2014 07:35:33

What steps will reproduce the problem? 1. Draw any diagram
2. Import an object from openclipart using the API in tools menu
3. Try resizing the object What is the expected output? What do you see instead? I should have been able to resize the object which never happens. What version of the product are you using? On what operating system? 2.0.5 on Ubuntu 14.04 Please provide any additional information below.

Original issue: http://code.google.com/p/evoluspencil/issues/detail?id=640

From zhukovki...@gmail.com on August 14, 2014 07:48:18

Same issue in version 2.0.5 under Windows 7

Same issue on Mac OS X Mavericks, Mac OS X Yosemite, Linux Debian Jessie and Ubuntu 14.04 LTE 64 bits... The issue seems to affect the svg file format, not only images coming from the open gallery.
A workaround is right click and edit on external application, but it is very time expensive.
Please, fix this issue.

MORE INFORMATION: I'll post this in a few places in an attempt to help figure out the problem. The open clipart browser will show size information next to the file name - certain ones have a size of "0x0" - THESE are the ones that will not be able to be resized. This appears to be an issues with open clipart, and not Pencil, but I'm not sure... just sharing the info! :)

Personal side note: the software is free and pretty awesome - let's not make nasty demands of the people putting time into creating and fixing this...

Thanks poppiesny for providing this information. I had a deeper look at the SVG files where the size was "0x0" vs. the ones where the size was displayed correctly. The problem seems to be the missing "width" and "height" attributes of the <svg> root Element. The non-working files only have a "viewBox" attribute which contains the width and height as a coordinate related to the reference point 0,0. The working files additionally have "width" and "height" attributes defined according to the values defined in the viewBox.

Example, non-working file:
`<svg
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ns1="http://sozi.baierouge.fr"
xmlns:cc="http://web.resource.org/cc/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
style="fill-rule:evenodd;text-rendering:geometricPrecision;image-rendering:optimizeQuality;clip-rule:evenodd;shape-rendering:geometricPrecision"
xml:space="preserve"
viewBox="0 0 1990 1253"

`

After adding the missing attributes manually the file worked fine in Pencil Project:
`<svg
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ns1="http://sozi.baierouge.fr"
xmlns:cc="http://web.resource.org/cc/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
style="fill-rule:evenodd;text-rendering:geometricPrecision;image-rendering:optimizeQuality;clip-rule:evenodd;shape-rendering:geometricPrecision"
xml:space="preserve"
width="1990"
height="1253"
viewBox="0 0 1990 1253"

`

But I don't think this is a problem of openclipart, because "width" and "height" are optional attributes regarding to the spec of SVG. It's an issue of Pencil that it needs those attributes. Somebody able to implement a workaround, like calculating this values and adding the attributes if they don't exist already?

An additional note to this. There are many cases where the resizing works, but wrongly. E.g. the SVG drawing imports but is much bigger than the box which is shown for sizing it.

Check your PrivateCollection.xml file.
Every item should be defined in there. Anything where the original dimension is 0,0 makes it so that Pencil can't calculate the scaling propery.

Work Around - With Pencil Closed

  1. Backup your PrivateCollection.xml file
  2. Open PrivateCollection.xml with Notepad or your text editor of choice. (Could take some time, mine is large.)
  3. Search for <p:property name="originalDim"><![CDATA[0,0]]></p:property>
  4. Change it to something like (For Something where the box size is 200x200):
    <p:property name="originalDim"><![CDATA[200,200]]></p:property>
  5. Save the file, and re-open Pencil

(Quick and dirty Search and Replace "" with "...But make sure you back up first.)