This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to set the paper size in skanlite?

Tags: None
(comma "," separated)
wolfi323
Registered Member
Posts
1129
Karma
11
OS
piedro wrote:Is this still developed for KDE 4?

Apparently yes. The last changes to the source code have been in November:
https://projects.kde.org/projects/playg ... repository

But you would have to compile it yourself I'm afraid (you can get the source code from the link above). I can't find packages for Arch either...

Seems to me like an even further regression ...

Well, the actual scanning is not done by kooka (or skanlite, for that matter) anyway. They both are just frontends to sane...
piedro
Registered Member
Posts
374
Karma
1
OS
thx. Is there a way to force sane to accept A4 papersize as default?

p.
colinkeenan
Registered Member
Posts
3
Karma
0
`skanlite` would be great if it could set the paper size. It's really easy to crop pictures using Gwenview though. What really prevents me from using `skanlite` is the way it treats the feeder. It uses an even longer page size than legal and then puts part of the next page on the current one filling all the extra long space. I can't find any GUI for scanning from the paper feeder tray properly. So, I ended up using `scanimage` from the command line.

`scanimage -h` will give you some of the useful parameters, but the really useful ones are going to be specific to your scanner.
`scanimage -A` will give you the parameters specific to your scanner

For my scanner, this is what I had to work with:

Code: Select all
/home/colin %scanimage -A

All options specific to device `hp5590:libusb:001:002':
    -l 0..215.889mm (in steps of 0.0999908) [0]
        Top-left x position of scan area.
    -t 0..297.699mm (in steps of 0.0999908) [0]
        Top-left y position of scan area.
    -x 0..215.889mm (in steps of 0.0999908) [215.889]
        Width of scan-area.
    -y 0..297.699mm (in steps of 0.0999908) [297.699]
        Height of scan-area.
    --mode Color|Gray|Lineart [Lineart]
        Selects the scan mode (e.g., lineart, monochrome, or color).
    --source Flatbed|ADF|ADF Duplex [Flatbed]
        Selects the scan source (such as a document-feeder).
    --resolution 100|200|300|600|1200|2400dpi [100]
        Sets the resolution of the scanned image.
    --extend-lamp-timeout[=(yes|no)] [no]
        Extends lamp timeout (from 15 minutes to 1 hour)
    --wait-for-button[=(yes|no)] [no]
        Waits for button before scanning
    --preview[=(yes|no)] [no]
        Request a preview-quality scan.


Using some of the above parameters and `--batch` from the general help, here's a basic line for scanning 8.5"x11" paper at 300dpi:

Code: Select all
scanimage --format=png --mode=Lineart --resolution=300 -y 279.386 --source=ADF --batch=out%03d.png


The width of 8.5" is default, so I don't specify it, but the to shorten the length from legal paper, I used `-y 279.386` where 279.386 is the number of milimeters. It's really just slightly less than 11" because the default width is slightly less than 8.5". This creates one png image for each page scanned: `out001.png out002.png ...`.

Setting the paper length (using default width) scans the full page. Setting the resolution ends up creating an image with the correct number of pixels. Unfortunately, for whatever reason, it doesn't encode the proper pixel density so that if I try to directly print the images, only a tiny part of each image fits on the page. It always acts as if it's a huge image at 96dpi instead of a one-page image at 300dpi.

So, to fix that problem, I use `convert` from the `imagemagick` package. For a single image, the fix would be:

Code: Select all
convert out001.png -density 300 out001.png


To do them all at once (assuming there are no other png files in the folder):

Code: Select all
for image in *.png; do convert ./"$image" -density 300 ./"$image"; done


Similarly, to convert the images into a pdf and fix the pixel density at the same time:

Code: Select all
for image in *.png; do convert ./"$image" -density 300 ./"${image%.png}.pdf"; done


`convert` can also combine all the images to one pdf, but it doesn't work with a lot of large images - I think it's doing everything in system memory. After converting all the images to pdf files, they can be quickly combined using `pdfunite`:

Code: Select all
pdfunite *.pdf out.pdf


I ended up creating a script (not the greatest in the world - feel free to improve on it) that works well for me after I define some aliases which i'll describe later. Here it is:

Code: Select all
 /home/colin %cat /usr/local/bin/scanit
#!/bin/bash
pdf=""
m=Lineart
res="300"
out=out
f=png

case "$2" in
   Color|Gray|Lineart)
      m="$2"
      echo --mode=$2 ;;
   -h|--help)
      printf "\nscant(scanb) [mode] [resolution] [filename.type] \n\n            mode: Color|Gray|Lineart \nresolution (dpi): 100|200|300|600|1200|2400 \n            type: pnm|tiff|png|jpeg \n\nUse - for default, so to just specify a filename and keep Lineart 300 defaults, scant - - outfile.pdf \nAlso, if specify pdf filetype, it will be converted to that from png.\n"
      exit ;;
   *)
      echo "Using default mode from Color|Gray|Lineart, --mode=Lineart" ;;
esac

case "$3" in
   100|200|300|600|1200|2400)
      res="$3"
      echo --resolution=$3 ;;
   *)
      echo "Using default dpi from 100|200|300|600|1200|2400, --resolution=300" ;;
esac

if [[ "$4" != "" ]]; then
   out="${4%.*}"
   [[ "$out" = "" ]] && out=out
   f="${4##*.}"
   case "$f" in
      pnm|tiff|png|jpeg)
         echo --format=$f ;;
      pdf)
         f=png
         pdf=pdf
         echo scans will be saved as png images and then combined into "$out".pdf ;;
      *)
         f=png
         echo "Using default file format from pnm|tiff|png|jpeg, --format=png" ;;
   esac
fi

if [[ "$1" = t ]]; then
   scanimage --format="$f" --mode="$m" --resolution="$res" -y 279.386 --source=ADF --batch="$out"%03d."$f"
else
    scanimage --format="$f" --mode="$m" --resolution="$res" -y 279.386 >"$out"."$f"
fi

if [[ "$pdf" = pdf ]]; then
   for image in *.png; do convert ./"$image" -density "$res" ./"${image%.png}.pdf"; done
   pdfunite *.pdf "$out".pdf
   rm "$out"?*.pdf
   echo created "$out".pdf
else
   for image in *.png; do convert ./"$image" -density "$res" ./"$image"; done
   echo created "$out"???."$f"
fi


I could just use `scanit t` to scan from the paper feeder tray, or `scanit b` to scan from the scanner bed, but instead, I created some aliases:

Code: Select all
alias scanb='scanit b'
alias scant='scanit t'
alias scanto='scanit t - -'


With these aliases, to scan in color from the scanner bed at 600 dpi and output to a jpeg file, it would be like this:

Code: Select all
scanb Color 600 out.jpeg


If I want to use the defaults but still give a filename, I would do:

Code: Select all
scanb - - myimage.png


It doesn't matter what I put for the 1st and 2nd parameter as long as there's something there that doesn't make sense, it will use the default. If I want to specify non-default options but can't remember what position I wanted each parameter to be in or what options are available, I use --help or -h:

Code: Select all
/home/colin %scanb -h

scant(scanb) [mode] [resolution] [filename.type]

            mode: Color|Gray|Lineart
resolution (dpi): 100|200|300|600|1200|2400
            type: pnm|tiff|png|jpeg

Use - for default, so to just specify a filename and keep Lineart 300 defaults, scant - - outfile.pdf
Also, if specify pdf filetype, it will be converted to that from png.


Normally, I want to scan from the tray using the defaults, but specify a filename, so that's what the last alias is for:

Code: Select all
scanto mydoc.pdf


If the file type is `pdf`, it automatically converts and combines into one pdf document.

This works well for me doing what the GUI scanner applications can't.
piedro
Registered Member
Posts
374
Karma
1
OS
Wow, you really dug into it! Great work and detail!

Though I switched to Gnome for the moment. Too much basic stuff like just scanning is missing from KDE.
It's more like a technical showcase of "What a desktop could do if there were applications for it"...

With KDE for me (maybe it's just me!) I cannot produce a productive workflow for normal office work:
No reliable E-Mail handling yet, no scanning for paperless office, no invoice management, no PIM integrated notes system... no addressbook integration in libreoffice... I am sure it's all possible (like you just proved impressively) I just can't do it...

Plasma looks great, I have to admit, but the basic stuff is so far behind the Plasma stuff that I wonder whether there is any chance of it catching up anytime soon.

Cheers, p.
User avatar
Arran
Registered Member
Posts
229
Karma
0
OS
Are you still talking about a HP product? If so, have you installed hplip from the repositories?
I never had any formatting problems, but neverless I changed to Epson because I don't work with All-in-ones. A scanner and a printer is what I have.


Best greetings from Scotland's nicest holiday island.
Kubuntu 18.04, 64 bits, Nvidia 4800GS, 8MB Ram, 4 core, HP Monitor 2550 x 1600 pixels.
piedro
Registered Member
Posts
374
Karma
1
OS
thx.

Yes I already use hplip but I am still on gnome - works for work.
KDE still doesn't ...

But you are right: HPlip does what I need to do, though simplescan (the gnome default scanning app, I guess) works alright too...

cheers, p.
jetzetle
Registered Member
Posts
1
Karma
0
I beg Your pardon guys - Thats now about 2012 that this question is heating here in the forum! And there is after TEN YEARS still no other solution than such a SILLY dully fully crazy proposition to change something important like a page format in a serious way!??? - Where are You living and what are You doing? Are You still clothing Your trousers with the pincers or to braking going upwards!?? .- I am using such an applikation every day to digitalize my orders and bills. And because my multifunctionprinter is too old there is no running driver from the manufacturer for the actual kde-version. - So I have to use this bloody scanlite soft or I have to change to Windows! - What do You think what I will do!?? - First I will abandon KDE, because such bloody soft is a mess and a insolence for me!
In what HELL are You living? Thats not the way to bring Linux or KDE in front!
je
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS
jetzetle wrote:I beg Your pardon guys - Thats now about 2012 that this question is heating here in the forum! ...

If you want to reach the skanlite developer (1 person, not multiple), the forum is the wrong place, and it has nothing to do with the Plasma developers. File a bug report, but please choose your wording more politely
https://bugs.kde.org/enter_bug.cgi?prod ... nt=general

FWIW, you could also have a look at skanpage. Depending on your distribution this relatively new application might already be available: https://apps.kde.org/de/skanpage/


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]