How do I export a ggplot as resizable image? - r

I'm working on a report with some coworkers in Google Docs (which will eventually be printed). We want to include some plots generated with ggplot. As we edit the document, the space for the images keeps changing slightly--often, we need to resize and/or change the aspect ratio of a plot slightly so that it fits on the page with the accompanying text.
Is there a way to export a ggplot object to an image that is resizable in the same way that plots can be resized in the Export dialog in RStudio?
Google Docs does not support SVG images--dropping an svg on the page simply opens the SVG itself (rather than adding it to the doc), so that's not an option.

Related

How to save effects applied by QtGraphicalEffects in QML

I have a QML based app which shall provide basic image editing. I have implemented cropping, and now I would like to add the effects provided by QtGraphicalEffects. I have added the effects to the QML, and added corresponding sliders, so I can add the effects to my image, which works well.
However, my question is, how I would be able to save those effects back to the image file? The problem is, that I am scaling down the image to fit the screen dimensions, therefore, saving directly from the QML / javascript would result in a shrinked image.
For the cropping part I have solved this by doing the cropping in C++, and re-opening the original image unscaled, and applying the cropping to the original image.
Could I do something similar in QML? E.g. when a save button is pressed, render the original image again in original size (off-screen, so its not visible), apply the effect, then save it? Is this possible?
You should be able to use an unscaled Image that has Item::visible: false, render all of the effects, and then use Item::grabToImage on the resulting rendering to save the result.
You can use Image::implicitWidth and Image::implicitHeight to get the native height and width of the original Image (before scaling).

How to Adjust Font Size of a ggplot in inkscape?

When I export ggplots from R (with ggsave in svg) to modify them in inkscape, I run into the following problem:
I use the text tool to select some text (axis labels for example). If I want to increase font size in the drop down menu, inkscape only increases the height of the text, width stays the same. I am left with text with the wrong aspect ratio.
This must be due to some type conversion (text to object for example) that is done at some point (ggplot, ggsave or inkscape). Until now I have been unable to figure out how to solve this. So far, I have reverted to deleting the existing text and creating new text in inkscape (adjusting font size works totally normally then)
Code to create input for Inkscape:
tdf <- data.frame()
tpl <- ggplot(tdf) + xlab("testtext")
ggsave(filename="tpl.svg",plot=tpl,height=5,width=8,device="svg")
It appears svglite introduces a textLength parameter which hard-codes the width. Interstingly, Illustrator seems to not care about this when editing the file, but Inkscape does.
You could try another device, svg may not be a great choice as it appears to split words into individual letters, but gridSVG::gridsvg seems to works. Or use a pdf device, which Inkscape can also import.

Rendering image with overlay Drupal 8

I'm building a Drupal website and I need to upload an image, some text and render that image with the text as overlay, maybe even a logo on top of it as well. Is there a module or a way to do this on Drupal 8?
Clarification: I need to generate a new picture and add overlay as pixel data.
Take a look at Image Effects module. According to readme it provides both - text overlay and watermark effects. If they are not sufficient for your needs you also have "ImageMagick arguments" effect, so nothing can stop you now ))

How do I use markdown to generate a PDF will full background-color/image bleed?

I have a simple markdown document that has either a background color or background image defined in the stylesheet I'm using to render it. When I export to PDF (using marked.app, mou.app, markdown pro, Multimarkdown Composer etC), I'd like that background to be full-bleed on the page with no margin or padding (i.e. no surrounding whitespace), much like something you'd create in illustrator.
Here is an example. (Reference the cover page). This will be used solely for on-screen consumption so I'm not worried about printing.
Can anyone suggest how to do this or a mac app that can do this?
Thanks!

How do I resize a flat vector icon so that it preserves hard edges?

I recently purchased Drew Wilson's Pictos icon library. It is a library of flat, monochromatic icons for use on the web and elsewhere. The only issue is: they're vectors. I know my way around Illustrator a little bit, but ultimately I want to import these icons into Photoshop CS4 and resize to various dimensions.
When I import an icon and resize it to, say, 20x20 pixels, I notice that there is a fair bit of aliasing around the edges of the icon. I'm sure there is some magic number where the edges of these icons will remain crisp, but I can't find any option or setting that will allow me to size these icons properly.
How can I snap these icons to the closest size that removes or minimizes the aliasing?
The aliasing / pixelating is because vectors export out of illustator # whatever size they're copied #
Try opening the icons in illustrator... scaling them waaay up
And then just keep a copy of the huge ones in a separate layer
Copy that layer when you want to scale it down ..annnd that way you'll have a copy to work with..and u won't have to re
Open the file every time u need to make an edit
And a good rule of thumb for pixelation is
You can always size down.. but sizing up will create pixelating in bitmaps
Chances are, you have your logo in .eps format. If you do, open your .eps file in Photoshop. A dialog box will pop up asking the size you want to import. Be sure to select RGB color if this will display on the web. Select the Anti-aliasing checkbox. When your file opens up, zoom in, and you'll notice that Photoshop has neatly anti-aliased all of your edges for you.

Resources