mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Provide endpoints to submit tasks to re-generate previews
The scaling factor can be given in the config file. When this changes, images can be regenerated via POSTing to certain endpoints. It is possible to regenerate just one attachment preview or all within a collective.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package docspell.extract
|
||||
|
||||
import docspell.extract.ocr.OcrConfig
|
||||
import docspell.extract.pdfbox.PreviewConfig
|
||||
|
||||
case class ExtractConfig(ocr: OcrConfig, pdf: PdfConfig)
|
||||
case class ExtractConfig(ocr: OcrConfig, pdf: PdfConfig, preview: PreviewConfig)
|
||||
|
@ -21,11 +21,13 @@ trait PdfboxPreview[F[_]] {
|
||||
|
||||
object PdfboxPreview {
|
||||
|
||||
def apply[F[_]: Sync](dpi: Float): F[PdfboxPreview[F]] =
|
||||
def apply[F[_]: Sync](cfg: PreviewConfig): F[PdfboxPreview[F]] =
|
||||
Sync[F].pure(new PdfboxPreview[F] {
|
||||
|
||||
def previewImage(pdf: Stream[F, Byte]): F[Option[BufferedImage]] =
|
||||
PdfLoader.withDocumentStream(pdf)(doc => Sync[F].delay(getPageImage(doc, 0, dpi)))
|
||||
PdfLoader.withDocumentStream(pdf)(doc =>
|
||||
Sync[F].delay(getPageImage(doc, 0, cfg.dpi))
|
||||
)
|
||||
|
||||
def previewPNG(pdf: Stream[F, Byte]): F[Option[Stream[F, Byte]]] =
|
||||
previewImage(pdf).map(_.map(pngStream[F]))
|
||||
|
@ -0,0 +1,3 @@
|
||||
package docspell.extract.pdfbox
|
||||
|
||||
case class PreviewConfig(dpi: Float)
|
Reference in New Issue
Block a user