officer generated document use same uploaded image - shinyapps

how does shiny handle temporary files?
I have an app where the user uploads images (one by one) and then via officer (and flextable) a document is generated
compose(i=1,j=1, value = as_paragraph(as_image(col1,width = 3.46,height = 2.63)),part = "body") %>%
compose(i=1,j=2, value = as_paragraph(as_image(col2,width = 3.46,height = 2.63)),part = "body")
but when I download the document, the images supposedly are different, but in the docx are the same.
This happens with temporary images. I know it's something with officer since it happened similarly with other segment of the document.
It didn't happened with uploading multiple images at once, but with consecutive fileInput's
is there a way to reset the image rendering or something?
Thank you

Since I used two or more fileInput to upload different images
R/Shiny creates a temporary folder, each one contains 0.jpg for all of the images uploaded
When using officeR to create the documents with images, it ignores the folder, and they all get confused since they are all named 0.jpg.
My solution was to filecopy each image from temporary folders to local folder, and renaming them, and then deleting all images contained.
(still have to try publishing the app but it sounds promising)
weird that it cannot differentiate different images from different (temporary) folders.

Related

Magmi | Overwriting images with the same image name as the Original

It appears when updating attributes & images, Magmi checks to see if the value you’re entering matches that value that already exists. In the case of images, it checks only file name, no other statistic about the file (such as size). If the value is the same, it does not proceed with replacing it. I loaded a lot of images and made the mistake of not re-sizing them before hand. So I re-sized the same images but when I overwrite it, it seems to ignore it keeping the original image i loaded in Magento. Anybody have a work around for this or something I can have updated to overwrite the images? I would hate to have to go through and rename all these images.
Thanks in advance,
Jim Browning

Resource pictures not include in directory

I am creating a vb6 application now and most of my command buttons were graphical style. Do the background images still show up even if I remove them from the app folder?
This is part of what goes into .FRX, .CTX, etc. files. Those are resource files created in a private "property bag" type format and are used to hold things like binary data, images, long strings, and so on.
But don't discard your source files, because you may need them down the road. Treat such things as valuable parts of the program source. They are not needed at run time though.
As far a I know it doesn't remove the picture from the command button when you delete it from the app folder, i suggest making a copy of your image and then delete the original and see if it works in case it doesn't you have the backup image, good luck.

How to link or add a default directory for images in Visual Basic

So I've been working on this simple program to look up specs for drawings. One of the specs is a thumbnail image of the drawing. I didn't want to try managing what could be 1000's of images (that could be changed at anytime) in the database so I created a true/false field instead. If true for that record, then the corresponding thumbnail is displayed in a picture box.
It works beautifully.... if I type the entire path in the code. But what if I give the program to a friend? So I've been trying to find a way that the program would find the images to no avail. I've been searching for answers all day and am finally at this point.... asking for help.
If CBool(db.getField("PDF")) = True Then
'pbxPDFThumb.ImageLocation = ("C:\Users\Reed Havoc\Desktop\RCM Database\RCM DataBase 2015 8g\RCM Plans Tool\RCM Plans Tool\Thumbnails\PDFs\" & db.getField("Plan_Num") & "pdf.jpg")
pbxPDFThumb.ImageLocation = ("\Thumbnails\PDFs\" & db.getField("Plan_Num") & "pdf.jpg")
End If
The first line is the entire path commented out to try the second, foreshortened path.
I've been adding my image thumbnail directory to the project in all the different directories that VS establishes on start-up but none seems to be a default so that my added image directory will be recognized.
Not so clear so I'll have 2 answers.
If drawing are not going to be added but you only use the ones you already have, simply store all of the pictures in the project's resource file, which is accessible through code and builds into the EXE
If the user adds drawings themselves there are two options. There's the more user friendly method: Save the files in a Local appdata folder for the application.
Or, less user friendly and ultimately more work for you. when the application starts, ask the user to identify a directory that does / will contain images.

How to extract images from a PSD file including images contained in a single layer

I don't have much knowledge of imaging tools but I need to extract images contained within the layers of a psd file. I tried using GIMP with a "save all layers" plugin but that is just saving the root layers so I am ending up with just two .pngs. I need every image in a separate file with the correct sizes.
The reason I need the files is that I have been asking to create an animation with CSS using the images. An example animations is at http://srv1.contobox.com/frontend/ads/preview.html?id=981
The psd document I am trying to extract is
https://www.dropbox.com/sh/ud2eaesej08o0g3/AAAi-_pPHGESOFOBpA0uQfjta
The problem is that these files are structured with Layer Groups (I opened just one of them).
While GIMP is supporting open the file, the "save all layers" plug-in you are using probably is not aware of layer groups.
(BTW, GIMP unstable - the 2.9 development version is likely currently broken for opening PSDs - the image opens garbled there. It opens in gimp 2.8.10, though)
It is possible to save all layers - including sublayers, as separate images with an interaction in the Python console.
With you PSD being the only image open in GIMP, go to filters->python->console and type something along this:
img = gimp.image_list()[0] # retrieves a reference to the image
folder = "/tmp/" # folder of you choice for saving the files
counter = 0
def save_recurse(item):
global counter
if hasattr(item, "layers"):
for layer in reversed(item.layers):
save_recurse(layer)
else:
counter += 1
name = folder + "layer_%03d.png" % counter
pdb.gimp_file_save(img, item, name, name)
save_recurse(img)
(btw, I typed it here in a way you can just copy and paste the listing above in GIMP's Python console)

folder structure for storing images

I have users who will have 2 types of picture images, + avatar image.
Which way is better
Users/picture1,Users/picture2, Users/avatar ?
Or
Picture1,Picture2,Avatar
Names of images will be stored in DB anyway.
So the question is better to store all avatars in one big folder or make separate folder for each user and there inside users folder make folders for avatar, picture and etc ?
Since folders are limited to a maximum number of files (not sure the actual number) then it probably makes sense to divide up the images by user. Of course, if the number of users is very, very large then you could hit a limit on the number of sub-folders.
Can the user have multiple avatar images and/or picture images (more than 2)? If not then it may be overkill to separate the avatar and picture images. Putting them in a single "User" folder or "User/images/" folder may be easiest.

Resources