Importing profile images to members personal portrait in Plone - plone

I'm trying to bulk upload portrait images to member profiles. Using the getPersonalPortrait function of mtool, I find that the object (FSImage) doesn't have the "data" attribute as the portraits with portrait images uploaded (Image).
How should I proceed to upload images to these member portraits without existing profile photos?

Create new OFS.Image() objects for uploaded portraits:
from OFS.Image import Image
portrait = Image(id=user_login, title='', file=fportrait)
membertool._setPortrait(portrait, user_login)
where fportrait is either an open file object or the image data as a string.

Related

Google docs does not preserve the file name when exported

I'm trying to export my Google Docs blog post which has the content and the images in it, I uploaded all the images with proper names such as my-cool-header.png
Now when I try to export it by any means via the Download, it has changed the names of the images to image.png, image-1.png, and so on.
So is there any way we can preserve the names of the images while we export them as Docx files?
Thank you
I don't think there is. I have not found any reference to check nor confirm the image details on the document aside from the Image options that only includes the following:
Image Options:
The Docs doesn't store anything from the image you included aside from the details above thus when opened in another document reader app, that app initializes the images' names into its own default image names (e.g image.png, image-1.png, etc.) as they didn't receive any details about it.
If alternative text is an option, you might want to try Alt text.
To access Alt Text, right click image -> Alt Text, or click image -> Ctrl+Alt+Y
Alt Text:
Try and see if filling up the Title and Description of the image in Google Docs shows under Alternative (Text only) and Description details of your image in the app you use to read the exported file.

Firebase cloud function image resize

Following the example here https://github.com/firebase/functions-samples/blob/master/generate-thumbnail/functions/index.js
How do I notify the client when the image is processed?
I want to have a form upload a photo and resize it to multiple sizes. How do I let the client know when the the cloud function is finished?
I'm using firebase/storage to upload the image client side, then I have a could function listening for files to be uploaded functions.storage.object().onFinalize and processing/resize the images. Is there a callback to the client when the cloud function is finished or to I need to setup pub/sub?
Your ultimate new images (the small ones - or whatever they are), would have some URL, let's say storageCompany.net/123123123123.jpg
So in your realtime Firebase, you will have some location that gives these URLs.
So maybe something like ..
user/NNNN/photos/thumbnails
so to be clear, you might have
user/NNNN/photos/thumbnails/726376733677.jpg
user/NNNN/photos/thumbnails/808080188180.jpg
user/NNNN/photos/thumbnails/363636636636.jpg
and now you're adding
user/NNNN/photos/thumbnails/123123123123.jpg
So indeed, your apps would simply watch for new items (ie, strings - the URLs) appearing in that location!
Just to be clear, let's say you have an ios or droid app that shows "any sort of images", and this is a Firebase project.
So, in your example is "thumbnail images" which are "created by a server".
But it just doesn't matter what sort of images you are showing.
In a
Firebase project, which
"Shows images"
The basic idea is simply what I explain above - you just have, one way or another, a Firebase location which has "the URLs of the images"
It's that simple!
Once the image is "ready" - no matter how that happens - upload, image being generated by 3D software .. whatever ..
That's how you make a Firebase project "with images". iOS, droid or www.
Of course there are many variations. In this example ..
we have a big folder with many "images". each "image" has many fields, including various actual image URLs (thumbnails, big thumbnails, videos, etc etc)
Precisely as you ask, the "thumbnail" (say) URL only appears when that image has been created and upload to some storage URL!
Enjoy
You will have to arrange for an exchange point between the client and your function. Typically, that will be some known location in the database where the function will write the result, and the client can listen for changes to know when the work is complete.
The example you're using will need to be modified to allow the client and server to agree on a unique location ahead of time.
There are two problems with Firebase image resizing - (1) it's tricky to notify the client once the image resizing is complete, and (2) you never know which exact size the client-side app may need (assuming you're building a responsive app).
These two issues can be solved by using a dynamic image resizing approach. The client app can upload images directly to Google Storage (via signed URLs and PUT requests), once the upload is complete it can request the resized image(s) right away. For example:
https://i.kriasoft.com/sample.jpg - original image
https://i.kriasoft.com/w_200,h_100/sample.jpg - dynamically resized image
The resized images can be cached in both the Google Storage bucket and at CDN.
$ npm install image-resizing --save
const { createHandler } = require("image-resizing");
module.exports.img = createHandler({
// Where the source images are located.
// E.g. gs://s.example.com/image.jpg
sourceBucket: "s.example.com",
// Where the transformed images need to be stored.
// E.g. gs://c.example.com/w_80,h_60/image.jpg
cacheBucket: "c.example.com",
});
https://github.com/kriasoft/image-resizing

Liip ImagineBundle custom resize without caching

I am using Liip ImagineBundle for managing the pictures in an auction listings project. The setup is as follows - when an auction listing is being created I am using Plupload to upload the picture set (with AJAX prior to persisting the auction). The pictures are uploaded into /pictures/temp folder with a temporary hash name. Upon persisting the entity, a Doctrine Subscriber renames the uploads in the temporary folder to use a format:
{AUCTION-ID}-{SIZE}-{TIMESTAMP}.{EXTENSION}
where the size is the version of the image - XL, large, medium, etc. and based on the timestamp creates a subfolder as:
/pictures/{YEAR}/{MONTH}/{DAY}/{PICTURE}
This allows for preventing millions of pictures to end up in a single folder and slow the file system. I am using a custom file loader and cache manager to resolve the pictures based on the timestamp. It all works perfectly fine but I have a request to display the uploaded pictures in a preview while doing the Plupload. The problem is in the resizing and caching with the ImagineBundle. What I would like to achieve is have the uploaded picture (the {HASH}.jpg in /pictures/temp) be resized to a specific size and at the same time a thumbnail to be generated off that as {HASH}-thumb.jpg. I know I can make it with another file loader and a cache manager but I was wondering whether it is possible to done via the bundle in some other way which is simpler as both these files are temporary ones and will be deleted upon the creation of the auction.

How to Display Uploaded Image from File System

I'm attempting to modify an inherited project that has a convoluted process of displaying uploaded images using an ImageMap control.
The current process inserts a new database record with image file name as well as model number and part number. The image files are saved to a virtual directory visible to IIS. Each part number has a corresponding .htm file containing an image map referencing the uploaded image. The image map has to be sized for each part and saved in the file system.
How can I streamline this process using either client side or server side controls? I'd like to bypass use of image maps as they require manual sizing. Can a control be used that auto sizes the image? Should the images be stored inside the database or kept in the file system?
Thanks for your advice;)
Storing the images in the database is IMHO a much more scalable solution.
Take a look at the Image Resizer project and its associated plugins for a way to resize the images, regardless of where you store them:
http://imageresizing.net/
http://weblogs.asp.net/bleroy/archive/2011/10/22/state-of-net-image-resizing-how-does-imageresizer-do.aspx
http://nathanaeljones.com/163/20-image-resizing-pitfalls/
You could use regular ASP.NET controls to display the images, for example, a ListView.

Where is the Alfresco PDF Preview saved?

when i click to the info Button next to the Filename in a Workspace there is shown a Preview of the PDF File, but i can't find this Preview in the Database or in the Filesystem, anybody know where it will be generated?
Regards
Rene
The flash preview of the PDF stored as a rendition of the actual document. It is stored as cm:thumbnail object as a child (rendition child association) of the PDF document and has the thumbnail name (i.e. thumbnails type) "webpreview".
Use the Alfresco Node Browser, find your PDF document and check it's child associations. You should find the webpreview there. From it's contentUrl you can even find the file in the content store (i.e. on you harddisk).
A preview should be an instance of a rendition in Alfresco. Nodes in Alfresco can have more than 1 rendition (e.g. different quality thumbnails). Renditions of nodes in Alfresco are themselves stored as nodes again, so you should be able to find them using the node browser in the admin panel.
If you navigate to the object using the Node Browser and look at its children, assuming you have already viewed the document in a document library list in Share and have opened the details page to see the preview, you'll see two children listed. One is named "doclib" and the other is named "preview". If you navigate to the doclib child, you will see that it is a PNG. That's the thumbnail shown in the document library list. If you navigate to the "preview" child, you'll see that its mimetype is Flash. That's the flash preview.
If you do not see the flash preview object it is possible that your pdf2swf binary isn't installed correctly or you haven't pointed to it properly in your alfresco-global.properties file.

Resources