This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 10 - Pages: 1 - Last Post: 28 Apr 26, 17:01 Last Post By: davidekholm Threads: [ Previous | Next ]
breisachers

Posts: 15
Registered: 20-Jan-2025
auto-generate thumbnail attachment for PDF
Posted: 25 Mar 26, 16:53
 
  Click to reply to this thread Reply
I've been away from jAlbum for a few months, I see the new "attachments" feature replaced the THM files, a very nice improvement, thanks! Last summer, I asked about the idea of having jAlbum automatically generate a thumbnail for a PDF file by taking a snapshot of the first page (see some of the conversation here: https://jalbum.net/forum/message.jspa?messageID=369108#369108). I still think this would be a nice feature - is it on a TODO list perhaps? As I mentioned in that previous thread, I have some java code that uses pdfbox (org.apache.pdfbox.rendering.PDFRenderer) to do this - I'm happy to contribute that code.
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 25 Mar 26, 21:30   in response to: breisachers in response to: breisachers
 
  Click to reply to this thread Reply
Thanks you. Yes, we should bump up the prio on implementing this. Thanks for wanting to contribute as well.
breisachers

Posts: 15
Registered: 20-Jan-2025
Re: auto-generate thumbnail attachment for PDF
Posted: 25 Mar 26, 21:53   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Here's a code snippet. It iterates over all the PDF files in a directory, captures an image of the first page and writes it out as a jpg.

Maven dependencies:
      <dependency>
      	<groupId>org.apache.pdfbox</groupId>
      	<artifactId>pdfbox</artifactId>
      	<version>3.0.7</version>
      </dependency>
      <dependency>
      	<groupId>org.apache.pdfbox</groupId>
      	<artifactId>pdfbox-tools</artifactId>
      	<version>3.0.7</version>
      </dependency


Code:
	final static int PAGE = 0;	
	final static int DPI = 96;
 
      File dir = new File("....");
      Collection<File> files = FileUtils.listFiles(dir, new String[] { "pdf" }, false);
      for (File file : files) {
      	PDDocument document = Loader.loadPDF(file);
      	PDFRenderer renderer = new PDFRenderer(document);
      	BufferedImage image = renderer.renderImageWithDPI(PAGE, DPI, ImageType.RGB);
      	String outputPrefix = FilenameUtils.removeExtension(file.getAbsolutePath());
      	String fileName = outputPrefix + ".jpg";
      	ImageIOUtil.writeImage(image, fileName, DPI, 1f);
      }
Let me know if you want more complete/details. Thanks for considering this feature.

(sorry for the poor/lack of indenting)

Edited by: breisachers on 25 Mar 2026, 13:56

Edited by: JeffTucker on 25 Mar 2026, 17:38, to add "code" tags
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 26 Mar 26, 12:20   in response to: breisachers in response to: breisachers
 
  Click to reply to this thread Reply
Thank you. I think that covers it.
breisachers

Posts: 15
Registered: 20-Jan-2025
Re: auto-generate thumbnail attachment for PDF
Posted: 26 Mar 26, 14:51   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Side question: Is there a list of TODO items somewhere? Or a "roadmap" or a bug/feature database (e.g. jira)? Just curious..
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 26 Mar 26, 15:38   in response to: breisachers in response to: breisachers
 
  Click to reply to this thread Reply
Currently I only maintain a private list, but it's a great idea that set up a public feature request voting system.
AnCa

Posts: 330
Registered: 25-Mar-2005
Re: auto-generate thumbnail attachment for PDF
Posted: 28 Mar 26, 01:51   in response to: breisachers in response to: breisachers
Helpful
  Click to reply to this thread Reply
breisachers wrote:
Is there a list of TODO items somewhere? Or a "roadmap" or a bug/feature database (e.g. jira)?
We have now deployed a roadmap service at https://roadmap.jalbum.net/ ! It is running "Fider", an open source web app for feature requests and suggestions. The server has only been up for a couple of hours, so we have just started filling it. You're all welcome to contribute.
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 28 Mar 26, 12:53   in response to: breisachers in response to: breisachers
 
  Click to reply to this thread Reply
pdf thumbnails within jAlbum will come in the next release
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 28 Mar 26, 17:34   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
39.4 beta available, now providing PDF previews:
https://jalbum.net/forum/thread.jspa?threadID=61020
breisachers

Posts: 15
Registered: 20-Jan-2025
Re: auto-generate thumbnail attachment for PDF
Posted: 25 Apr 26, 22:11   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Nice, thanks for doing this!
davidekholm

Posts: 3,996
Registered: 18-Oct-2002
Re: auto-generate thumbnail attachment for PDF
Posted: 28 Apr 26, 17:01   in response to: breisachers in response to: breisachers
 
  Click to reply to this thread Reply
You're welcome!
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums