mobian, pinephone camera, and megapixels
#11
(03-25-2021, 01:32 PM)calinb Wrote: In an attempt to learn / debug the behavior of the script and its interaction with Megapixels output, I renamed some .dng files in my Pictures folder to 1.dng, 2.dng, 3.dng, etc. Then I issued the command.

"/usr/share/megapixels/postprocess.sh /home/mobian/Pictures test"

and the result was it deleted my entire Pictures subdirectory with all my (wanted) pictures in it! Cry

I'm sorry to read you lost your images, but you are absolutely right, reading only the introductory comment lines, especially the last two of them, would have helped:

# The post-processing script is responsible for cleaning up
# temporary directory for the burst.


I can confirm that the software combination (Megapixels with the current postprocessing script) just produces .dng files. Curiously, if I manually prepare files and start the script, it does produce .jpg files:

Maus@pine:~$ bash -x /usr/share/megapixels/postprocess.sh /tmp/test test
+ '[' 2 -ne 2 ']'
+ BURST_DIR=/tmp/test
+ TARGET_NAME=test
+ MAIN_PICTURE=/tmp/test/1
+ cp /tmp/test/1.dng test.dng
+ DCRAW=
+ TIFF_EXT=dng.tiff
+ command -v dcraw_emu
+ '[' -x /usr/lib/libraw/dcraw_emu ']'
+ DCRAW=/usr/lib/libraw/dcraw_emu
+ set -- -fbdd 1
+ CONVERT=
+ command -v convert
+ CONVERT=convert
+ set -- -fbdd 1
+ '[' -n /usr/lib/libraw/dcraw_emu ']'
+ /usr/lib/libraw/dcraw_emu +M -H 4 -o 1 -q 3 -T -fbdd 1 /tmp/test/1.dng
+ '[' -n convert ']'
+ '[' convert == convert ']'
+ convert /tmp/test/1.dng.tiff -sharpen 0x1.0 test.jpg
+ command -v exiftool
+ exiftool -tagsFromfile /tmp/test/1.dng.tiff -software=Megapixels -overwrite_original test.jpg
    1 image files updated
+ echo test.jpg
test.jpg
+ rm -rf /tmp/test

Works as designed, I'd say, so I have to inspect Megapixels why it does not call the postprocessing that way (or why it fails to do so).
  Reply
#12
(03-25-2021, 02:56 PM)Maus Wrote: I'm sorry to read you lost your images, but you are absolutely right, reading only the introductory comment lines, especially the last two of them, would have helped:

# The post-processing script is responsible for cleaning up
# temporary directory for the burst.

<snip>

Thanks, Maus! Yeah, I'm not much of a script meister so sometimes I take heuristic shortcuts to study behavior rather than studying the code. I've been in computing since before "microcomputers" even existed. FORTRAN, K&R C, and assembler is mostly how I learned a living many years ago.

But at least I finally settled into reviewing the code and I found the bug. I guess it's best to stick to POSIX syntax when using sh and perhaps a new intolerance to legacy code just bit postprocess.sh!

I changed line 69 in postprocess.sh from
Code:
if [ "$CONVERT" == "convert" ]; then

to

Code:
if [ "$CONVERT" = "convert" ]; then
I setup test subdirectories and ran the script from the terminal and it worked only with the change in operator syntax. I have .jpg files now! Big Grin

From https://stackoverflow.com/questions/2044...erators-eq

== is a bash-ism, by the way. It's better to use the POSIX =. In bash the two are equivalent, and in plain sh = is the only one guaranteed to work.

Now I need to discover where to file a bug report.
  Reply
#13
(03-25-2021, 04:53 PM)calinb Wrote: But at least I finally settled into reviewing the code and I found the bug. I guess it's best to stick to POSIX syntax when using sh and perhaps a new intolerance to legacy code  just bit postprocess.sh!

Great find! The funny thing is, just a week ago I sort of lectured interpreter agnostic shell scripting to my apprentice, with exactly this as a common example, but I didn't spot the problem here ... I'm also getting older every day.

This has already been fixed by Martijn, and will probably land in Mobian soon.
  Reply
#14
(03-26-2021, 01:38 AM)Maus Wrote: Great find! The funny thing is, just a week ago I sort of lectured interpreter agnostic shell scripting to my apprentice, with exactly this as a common example, but I didn't spot the problem here ... I'm also getting older every day.

This has already been fixed by Martijn, and will probably land in Mobian soon.

Thanks for the comment and link to Martijn's latest code. Lacking a way to file a bug report, I sent Martijn an email and apparently he fixed the script very promptly (9 hours ago)!
  Reply
#15
As graphicsmagick compatibility has been added I tried swapping imagemagick for graphicsmagick and this also works as a quick fix, just in case..
  Reply
#16
(03-26-2021, 04:18 AM)battlegarden Wrote: As graphicsmagick compatibility has been added I tried swapping imagemagick for graphicsmagick and this also works as a quick fix, just in case..

Yes. Good point. After the script's existence test for imagemagick errors, due to the bash-ism, it will use gm, if installed. I've not looked into gm but maybe it's a better choice than im for this usage anyway, because I suspect gm may be a lighter weight program and the im GUI doesn't seem terribly usable on PinePhone Mobian to me.

But, for the first time, I'm now getting .jpg files in my Pictures folder using Megapixels so "if it works, don't fix it" is the approach I'm sticking-with! Wink
  Reply
#17
Hello there,

has anyone found out how to tell megapixels where to store the jpegs? In my case, it's plain $HOME and I want to change it (back) to $HOME/Pictures.

Thanks in advance!

Cheers!
  Reply
#18
(03-26-2021, 05:20 AM)arno_nuehm Wrote: has anyone found out how to tell megapixels where to store the jpegs? In my case, it's plain $HOME and I want to change it (back) to $HOME/Pictures.

This is determined programmatically here. I' not sure how files could end up directly in $HOME, though. If the environment is sane, files should show up in (a localised version of) $HOME/Pictures. Perhaps you changed your locale to something non-English and it would have saved to $HOME/Eikones (for example) if only the folder would have existed ... but the last else would have catched that!
  Reply
#19
(03-26-2021, 05:20 AM)arno_nuehm Wrote: Hello there,

has anyone found out how to tell megapixels where to store the jpegs? In my case, it's plain $HOME and I want to change it (back) to $HOME/Pictures.

Thanks in advance!

Cheers!

Megapixels passes the folder and filename (without extension) as arguments to postprocess.sh and I don't know how to configure this megapixels behavior but there's probably a configuration file that will do it. Maybe have a look at the source code at the link posted by Maus above or maybe someone here knows how to do it.

I see no files in /home/mobian/.config/megapixels but it might be the location where such a configuration file would go and you just need to create a valid configuration file.

If you can't find a megapixels configuration solution, you could modify the postprocess.sh script to move the files (*.jpg or whatever) from $HOME to $HOME/Pictures after they are written.
  Reply
#20
I just used Megapixels for the first time months while and I'm finding it's producing dng files instead of the jpg format it was previously saving. (A couple of pictures I took and saved back in January with Megapixels are in jpg format.) Both dcdraw and imgmagick are installed. Also, what exactly does Megapixels do with the QR code? I can see it zeroing in on the code and there's some tiny text which I assume is the decoded content, but all it seems to actually do is save the QR as a dng image. What does it do with the QR code data?

EDIT: In another thread I was informed that tapping the screen copies the QR code data - puts it into the paste buffer? How to retrieve it or use it?
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pinephone in Canada using Shaw mobile provider RRman 0 52 06-19-2021, 06:35 PM
Last Post: RRman
  Reboot Modem on Pinephone in Mobian eggmatters 5 519 06-17-2021, 02:08 PM
Last Post: eggmatters
  Axolotl on PinePhone / Mobian arno_nuehm 93 22,182 06-11-2021, 07:16 AM
Last Post: ergo owl
  Mobian not updating via Software app FOSSagent0 2 235 06-07-2021, 09:22 PM
Last Post: Zebulon Walton
  mobile data on mobian not working synaption 1 177 06-02-2021, 03:16 PM
Last Post: Aberts10
  How do you copy and paste into mobian terminal? Do you ssh instead? temp0rary 6 311 06-01-2021, 12:16 PM
Last Post: temp0rary
  Turn by Turn alternative GPS app in Mobian livanti21 27 12,412 05-30-2021, 03:17 AM
Last Post: john_doe
  Pinephone ”reboot” or logging out by itself Wahtone 0 146 05-28-2021, 09:32 AM
Last Post: Wahtone
  Can't update OS Mobian Phosh Gon 5 502 05-23-2021, 10:52 PM
Last Post: pajux
  Mobian: 2 week as main phone steves 10 1,529 05-18-2021, 11:55 AM
Last Post: vortex

Forum Jump:


Users browsing this thread: 1 Guest(s)