I'd like to convert this SVG to PDF with the size scaled up to x10 of it's current size without losing the quality of the picture. The PDF should also be in 300 PPI. How can I achieve kind of output?
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="248.1" height="350.7" viewBox="0 0 248.1 350.7" xml:space="preserve">
<desc>Created with Fabric.js 1.7.19</desc>
<defs>
</defs>
<g transform="translate(51.2 34.1) scale(0.1 0.1)">
<image xlink:href="./cat.jpg" x="-512" y="-341" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" width="1024" height="682" preserveAspectRatio="none"></image>
</g>
</svg>
This SVG came from fabricjs toSVG() code. I can resize it using fabricjs, but I'd like to know is it possible to do this and how using ImageMagick.
ImageMagick is a programm suite aimed at raster images. What you have is a format that mixes vector and raster content both for input and output.
ImageMagick can handle that, but only through additional programs that need to be installed:
import from SVG with Inkscape or librsvg
export to PDF with ghostscript
You can cutout the middleman. Inkscape, while being mainly a SVG editor GUI, also has a commandline mode, for example for export tasks. You can scale the SVG by multiplying the height and width values on the root element with your scale - do not change the viewBox attribute:
<svg width="2481" height="3507" viewBox="0 0 248.1 350.7" ...>
Or, if you know the target size of the pages you want, you can set them. Even if aspect ratio does not fit, your content will sized-to-fit on the page. For example with a A4 page:
<svg width="210mm" height="297mm" viewBox="0 0 248.1 350.7" ...>
Then execute Inkscape:
inkscape --without-gui --export-pdf=out.pdf in.svg
Pictures are embeded as-is, so you do not loose resolution.
Related
In Windows 10, I use ImageMagick-7.0.10-Q16. When I execute this command-line:
magick clocky.svg test.pdf
... then I get a PDF where the image in the PDF is very pixelated:
This is the source SVG image: https://svgshare.com/s/V0f
How can I get an optimal result when converting SVG to PDF without pixelation with ImageMagick?
Isn't there a way to include the SVG natively in the PDF, so the image in the PDF looks always smooth at all zoom values? (Like it is obviously done by Inkscape when saving an SVG to PDF).
In ImageMagick, you would specify a density before reading the SVG and then resize afterwards. So
magick -density 288 clocky.svg -resize 25% test.pdf
288=4*72 so we resize by 1/4=25%
I've been experimenting with SVG filters, but can't figure out how to fix this: I have an SVG that uses filter effects like feBlend:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="70 0 360 360">
<defs>
<path id="orange" d="M200,50 a35 35 0 0 1 100 0 l0 70 a40 40 0 0 1 -100 0 z" fill="rgb(252,170,30)"></path>
<path id="yellow" transform="rotate(45 250 185)" d="M200,50 a35 35 0 0 1 100 0 l0 70 a35 35 0 0 1 -100 0 z" fill="rgb(242,229,0)">
<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 250 180" to="45 250 180" dur="1.5s" additive="replace" fill="freeze"/>
</path>
…
<filter id="blendit">
<feImage xlink:href="#orange" x="0" y="0" result="1"/>
<feImage xlink:href="#yellow" x="0" y="0" result="2"/>
…
<feBlend mode="multiply" in="1" in2="2" result="12"/>
<feBlend mode="multiply" in="12" in2="3" result="123"/>
…
</filter>
</defs>
<rect x="0" y="0" width="500" height="500" filter="url(#blendit)"/>
</svg>
When included on the page as inline SVG, the graphic displays sharp on an iOS retina screen.
However, if I try to use it as a source for an <img> tag:
<img src='svg-with-filters.svg'/>
The graphic appears fuzzy, as if it was an #1x resource on the retina screen.
How do I force the graphic to appear sharp on iOS, without resorting to inline SVG or an <object> tag? It renders correctly on desktop Chrome and on Android devices.
Example
Here's a CodePen that demonstrates the problem, and a screenshot below.
i want to know the position of the chart when i move the scrollbar in the highchart . is there any scrollbar event associated in highchart .Please help .
The Highcharts API does not show any event handling options for the scrollbar.
Let's take a look at the code in their example. Here is the SVG that renders the scrollbar itself.
<g class="highcharts-scrollbar" transform="translate(10,372)">
<rect x="0" y="-0.5" fill="white" stroke="silver" stroke-width="1"
rx="7" ry="7" height="14" width="580"></rect>
<rect y="0" height="14" fill="gray" rx="7" ry="7" x="358"
width="18"></rect>
<path fill="none" stroke="yellow" stroke-width="1"
visibility="visible"
d="M 363.5 3.5 L 363.5 9.333333333333334 M 366.5 3.5 L 366.5 9.333333333333334 M 369.5 3.5 L 369.5 9.333333333333334"></path>
<g>
<rect x="-1" y="-1" width="15" height="15" strokeWidth="0" rx="7" ry="7" fill="gray"></rect>
<path fill="yellow" d="M 8 4 L 8 10 5 7"></path>
</g>
<g transform="translate(566,0)">
<rect x="-1" y="-1" width="15" height="15" strokeWidth="0" rx="7" ry="7" fill="gray"></rect>
<path fill="yellow" d="M 6 4 L 6 10 9 7"></path>
</g>
</g>
The scrollbar position is the 2nd <rect> tag. You can use jQuery to retrieve the value of attribute x. In the example code, the position of x = 358 out of the maximum 580 space (the '' with which filling).
The following issue happens in Firefox 20.0.1 and IE10, but works in Chrome.
When I test a highchart plot in Firefox 20.0.1 or IE10, the chart series is invisible. After looking into the chart html, I found the clipPath in the SVG is not set correctly.
There are 4 "clipPath" defined in the "defs" section, as follows:
`
<defs>
<clipPath id="highcharts-1">
<rect height="110" width="9999" y="0" x="0" fill="none" ry="0" rx="0"></rect>
</clipPath>
<clipPath id="highcharts-2">
<rect height="0" width="1228" y="0" x="0" fill="none"></rect>
</clipPath>
<clipPath id="highcharts-14">
<rect height="0" width="0" y="0" x="0" fill="none"></rect>
</clipPath>
<clipPath id="highcharts-15">
<rect height="110" width="99" y="-40" x="-99" fill="none" ry="0" rx="0"></rect>
</clipPath>
</defs>
`
In the "highcharts-series" "g" tag, it uses "clip-path="url(#highcharts-14)"". Which causes the chart series invisible. If I manually change the clip-path to url(#highcharts-2), chart shows up.
Since I didn't set any clipPath related options in the highchart, why the "highcharts-14" and "highcharts-15" get defined and used? How to fix this issue?
Thanks,
I have many images (*.pdf) that originally do not have margin. The files are in various sizes but usually from 8000x4000 to 20000x14000 px.
I use this command to convert them to jpeg:
for /r %x in (*.pdf) do convert -density 400 -quality 100% "%x" "%x.jpg"
But it produces big margins. Margins take 30% of the image size. So I need to prevent them or to crop them. I tried to look in IM manual to find how to obtain width and height and to substract some value and to add it to -crop. But this his too hard to me, I am tring to solve it about 1,5 hours without result. And I am new to IM. Can somebody tell me how to solve this and remove the margin?
Also I would like to repair name of file from e.g. map.pdf to map.jpg Now it result in map.pdf.jpg
I used this code to crop the image after conversion to raster:
for /r %x in (*.pdf) do convert -density 400 -shave 1600x1600 -quality 34% "%x" "%x.jpg"