Automatically generate article covers/thumbnails from PDF

Dear all
are there any thoughts to create a plugin or tool that automatically generates article covers from PDFs (in the sense of thumbnails)?
Using the systematic paths to each PDF, let’s use php-gd to either once iterating through all published PDFs to create a thumbnail of the first page of each PDF and store the info to the db.
Or generate a jpg on the fly into the cache - meaning more server load but less iteration.
Or what about a #bash script for the /tools to be run on demand for back issues?

Does anyone have some pieces of code for that?

Thanks and all the best
Klaus

1 Like

Hello @klausru,

Thanks for your post. My search of the forum and Github issues seems to suggest that such a feature has not been explored. If you’re not familiar with it, you may wish to check in our plugin development guide: Plugin Guide for OJS and OMP

Having the ability to include an article cover manually has generally been the approach taken in OJS as it gives editors/journal managers more control. Others may also wish to weigh in on the feasibility of developing such a feature/plugin.

Best regards,

Roger
Public Knowledge Project Staff

Dear @rcgillis , dear @mpbraendle , dear all
this is to let you know what I have done so far.

Personally, I think this is pretty cool so far.
All the best
Klaus

2 Likes

Hi @klausru,

Thanks for sharing! Flagging this for @Vitaliy and @NateWr as well, as they have both been involved in theming and may want to have a look at this.

-Roger
PKP Team

1 Like

That’s cool, @klausru! Do you have a link to this being used in production? I’d love to see some of the generated images.

Dear @NateWr
have a look at Themenhefte | MedienPädagogik: Zeitschrift für Theorie und Praxis der Medienbildung
or e.g. Heft 42: Optimierung in der Medienpädagogik. Forschungsperspektiven im Anschluss an den 27. Kongress der DGfE | MedienPädagogik: Zeitschrift für Theorie und Praxis der Medienbildung
You will see two different designs that we are corrently testing. All images are in /public/journals/1/covers.
One more design will be tested where I try to write elements from the db directly into the svg.

Thanks @klausru, those look really great. I think there would be a lot of interest in a plugin that could render a cover image based on the title of the article / issue. Especially if it could be fairly easily configured with the journal logo.

1 Like

Dear @NateWr , dear all
based on your encouragements I’ve started to put elements together. It’s not yet a plugin, but still a hack within the theme. It already shows opportunities, difficulties and nice to haves:

Opportunities and challenges

  • Building an inline SVG is very easy. You could even put endless inline SVGs within an SVG
  • inline SVGs can be easily styled by CSS
  • <img> and <svg> placements behave differently: while <img> is easy to use, you can only manipulate its content via CSS with filter: .... The style of <svg> is fully able to be manipulated
  • it could be shown, that the three basic elements logo, background and text elements are either already variables in the system or could be stored as such (in case of background)
  • a form for the settings in the dashboard would be nice, but usually is only needed once for the setup
  • the greatest challenge: all elements within the cover.tpl-SVG need placements by x="..." and y="...". The cover.tpl-SVG itself only needs a viewBox="..." in pixel values; the rest is maintained by bootstrap and does the responsivity.
  • thus a form for the settings would need:
    ** an upload field for the background file or decorative styling
    ** some, at least, basic WYSIWYG (visual) styler to set the values for placing the elements
  • I haven’t found out yet, how to manipulate a template with a plugin
  • the rendered image quality of the smaller SVGs is not entirely convicing. Therefore check the mobile view, too.

See the stuff working at: Themenhefte | MedienPädagogik: Zeitschrift für Theorie und Praxis der Medienbildung and in the theme linked above.
Comments and suggestions are welcome

All the best
Klaus

3 Likes

This is really cool. I love that you’re doing this all with SVG, instead of trying to generate and render a raster image on the server. That opens up a lot of possibilities for adopting a technique like this into the core application, or a default theme, because colors could adapt to the journal’s theme’s colors.

This can be tricky because you effectively need to parse the template string, split it at the point you want, and insert your own content. It is usually easier to simply override the whole template file.

Thanks for sharing this @klausru. I have been thinking about something similar but never got to actual coding of anything.

Happy to help out if you start to work on a plugin. I have some experience with smarty filters Nate is referring to.