mobian, pinephone camera, and megapixels
#28
(04-28-2021, 04:29 PM)NormandC Wrote: ...

(04-28-2021, 04:16 PM)calinb Wrote: I thought I described my fix in my last posts in this thread (after mucking my way through the debug effort).

You did, and I applied your fix a couple weeks ago. Thanks for that!

- Norm

+1 thanks to @calinb 

As identified the "silver bullet" in megapixels is the post-processing script.
  • The basic camera output is a raw .dng format
  • It is converted to .TIFF if dcraw is installed
  • The .TIFF is converted to .jpg if imagemagick is installed
  • The .jpg file gets some exif data if libimage-exiftool-perl is installed (in Mobian - Arch has a different name for it)
I don't have a note on what any default Mobian config has but for sure I always ensure I have dcraw, imagemagick and libimage-exiftool-perl packages installed each time I rebuild my Mobian system.

The other nugget for postprocess.sh is if you put a version in ~/.config/megapixels/ then that is used in preference to the default in /usr/share/megapixels/ . Which will survive any upgrades and can do stuff the way you prefer. So my version has 3 mods:
  1. the @calinb / v0.16 patch
  2. I have commented out the initial copy of the .dng file to /Pictures as I dont want to preserve any raw images
  3. I have added an exiftool line (and suggested it to Martijn) to set the DateTimeOriginal tag. (Because the package I use for my media library, fotoxx, can sort on that tag!)
My version
Code:
$ cat .config/megapixels/postprocess.sh
#!/bin/sh

# The post-processing script gets called after taking a burst of
# pictures into a temporary directory. The first argument is the
# directory containing the raw files in the burst. The contents
# are 1.dng, 2.dng.... up to the number of photos in the burst.
#
# The second argument is the filename for the final photo without
# the extension, like "/home/user/Pictures/IMG202104031234"
#
# The post-processing script is responsible for cleaning up
# temporary directory for the burst.

if [ "$#" -ne 2 ]; then
    echo "Usage: $0 [burst-dir] [target-name]"
    exit 2
fi

BURST_DIR="$1"
TARGET_NAME="$2"

MAIN_PICTURE="$BURST_DIR"/1

# Copy the first frame of the burst as the raw photo
# cp "$BURST_DIR"/1.dng "$TARGET_NAME.dng"

# Create a .jpg if raw processing tools are installed
DCRAW=""
TIFF_EXT="dng.tiff"
if command -v "dcraw_emu" > /dev/null
then
    DCRAW=dcraw_emu
    # -fbdd 1    Raw denoising with FBDD
    set -- -fbdd 1
elif [ -x "/usr/lib/libraw/dcraw_emu" ]; then
    DCRAW=/usr/lib/libraw/dcraw_emu
    # -fbdd 1    Raw denoising with FBDD
    set -- -fbdd 1
elif command -v "dcraw" > /dev/null
then
    DCRAW=dcraw
    TIFF_EXT="tiff"
    set --
fi

CONVERT=""
if command -v "convert" > /dev/null
then
    CONVERT="convert"
    # -fbdd 1    Raw denoising with FBDD
    set -- -fbdd 1
elif command -v "gm" > /dev/null
then
    CONVERT="gm"
fi


if [ -n "$DCRAW" ]; then
    # +M        use embedded color matrix
    # -H 4        Recover highlights by rebuilding them
    # -o 1        Output in sRGB colorspace
    # -q 3        Debayer with AHD algorithm
    # -T        Output TIFF
    $DCRAW +M -H 4 -o 1 -q 3 -T "$@" "$MAIN_PICTURE.dng"

    # If imagemagick is available, convert the tiff to jpeg and apply slight sharpening
    if [ -n "$CONVERT" ];
    then
        if [ "$CONVERT" = "convert" ]; then
            convert "$MAIN_PICTURE.$TIFF_EXT" -sharpen 0x1.0 "$TARGET_NAME.jpg"
        else
            gm convert "$MAIN_PICTURE.$TIFF_EXT" -sharpen 0x1.0 "$TARGET_NAME.jpg"
        fi

        # If exiftool is installed copy the exif data over from the tiff to the jpeg
        # since imagemagick is stupid
        if command -v exiftool > /dev/null
        then
            exiftool -tagsFromfile "$MAIN_PICTURE.$TIFF_EXT" \
                 -software="Megapixels" \
                 -overwrite_original "$TARGET_NAME.jpg"
            exiftool -tagsFromFile @ "-ModifyDate>DateTimeOriginal" -overwrite_original "$TARGET_NAME.jpg"
        fi

        echo "$TARGET_NAME.jpg"
    else
        cp "$MAIN_PICTURE.$TIFF_EXT" "$TARGET_NAME.tiff"

        echo "$TARGET_NAME.tiff"
    fi
fi

# Clean up the temp dir containing the burst
rm -rf "$BURST_DIR"
  • PinePhone BraveHeart now v1.2b 3/32Gb daily driver, Tow-boot with pmOS/SXMO on eMMC
  • PinePhone pmOS Community Edition 2/16Gb driving my picture frame, Tow-boot with pmOS/SXMO on eMMC
  • PinePhone Pro Explorer Edition, Tow-boot on SPI, Arch/SXMO on eMMC
  • ROCKPro64 v2.1 2GB, 16Gb eMMC retired in favour of a fruity upgrade
  Reply


Messages In This Thread
RE: mobian, pinephone camera, and megapixels - by dukla2000 - 04-29-2021, 04:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  bookworm vs trixie discussion for mobian in pinephone regular. zetabeta 65 27,223 07-12-2025, 07:46 AM
Last Post: anonymous
  cryptocurrency on mobian/pinephone biketool 33 52,466 06-30-2025, 02:57 PM
Last Post: biketool
  XLibre for Mobian Hiraghm 1 592 06-30-2025, 01:38 AM
Last Post: Haroldkent
  Axolotl on PinePhone / Mobian arno_nuehm 223 253,667 06-25-2025, 01:19 PM
Last Post: anonymous
  VoIP account on mobian dialer j_s 0 437 06-15-2025, 04:19 PM
Last Post: j_s
  Mobian Pinephone Notification LED biketool 2 713 06-07-2025, 03:19 PM
Last Post: KC9UDX
  Vivaldi Web browser nearly native for Mobian biketool 3 1,143 05-06-2025, 02:19 AM
Last Post: biketool
  mobian calamares fail merom 2 1,172 04-29-2025, 02:10 PM
Last Post: mdk
  New camera app gnome-snapshot working on trixie? vusra 4 1,352 04-11-2025, 02:53 AM
Last Post: vusra
  Pinephone seems tobe using 4G data instead of Wifi data grump_fiddle_reinstall 7 3,293 02-20-2025, 02:47 PM
Last Post: puffchumpy

Forum Jump:


Users browsing this thread: 1 Guest(s)