photog.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A place for your photos and banter. Photog first is our motto Please refer to the site rules before posting.

Administered by:

Server stats:

248
active users

#python3

0 posts0 participants0 posts today

Und gleich noch 'ne Frage, diesmal zu #Python3: Kann es sein, daß piexif beim Ersetzen von Exif-Daten das ganze Exif-Gedöns zerschießt?

exifdict['Exif'][piexif.ExifIFD.DateTimeOriginal] = rtime

– wobei rtime ein DateTime-Objekt ist; ich versuche, fehlerhafte Zeitstempel zu korrigieren)

Vor dem Edit sind die Exif-Daten OK, danach heißt es: beschädigt.

Und ja, ich hatte mich mit dem Thema vor drei Jahren schonmal befaßt, war aber an genau diesem Problem gescheitert und hatte dann erstmal aufgegeben.

WARNING: Awesome code follows

I just read there is a more accurate way to calculate a dog's age in human years than simply multiplying by 7 (which does produce a lot of oddities, especially when it comes to dogs giving birth at "7" years old lol). The progression through the first, second and then subsequent years are handled in a manner that is much closer to how dogs typically age compared to humans.

Here are #lisp and #python functions demonstrating the new calculations. Feel free to use them as you wish. Especially if you have one or more dogs.

Feel free to improve or comment on the code in the comments or elsewhere. I always post these kinds of functions for conversation and community, I'm just learning python, so don't bark too loudly.

The formats are:

(dogs-age years months)
and
dogs_age(years, months)

There is no error checking, so use zeros when necessary.

Don't be strangers. Shake a paw!

#commonlisp

(defun dogs-age (years months)
"Calculate the human age equivalent of a dog given its age in years and months."
(let ((human-age 0))
(cond
((< years 1)
(setq human-age (* (/ months 12.0) 15)))
((= years 1)
(setq human-age (+ 15 (* (/ months 12.0) 9))))
((>= years 2)
(setq human-age (+ 15 9
(* (- years 2) 5)
(* (/ months 12.0) 5)))))
human-age))

#python3

def dogs_age(years, months):
"""
Calculate the human age equivalent of a dog given its age in years and months.
"""
if years < 1:
human_age = months * (15 / 12)
elif years == 1:
human_age = 15 + months * (9 / 12)
else:
human_age = 15 + 9 + (years - 2) * 5 + months * (5 / 12)

return human_age

Hey, @praetor you might be interestd in this, even if it isn't about cats. If you change the subsequent years from 5 to 4, it'll work for cats just the same, apparently. :ablobdj:

Replied in thread

That's probably enough coding for tonight. I got all the REST endpoints I think I need for now and have extremely basic tests written for them. The tests check the return code is 200 and the integer returned is the right number.

On the actual implementation of the functions, I'm returning some number that the test is looking for so I know I'm getting to the right function.

I am kinda curious if there's a test coverage tool that will tell me how much of my code is running when I run the tests. There's probably something in pytest for that which I can research another time. Rather than trying to hit 100%, I would use it to find out if I'm missing anything as I keep adding code.

I'm trying to learn Python scripting for meshtastic using their API. However, I cannot find documentation that lists (and explains) the available functions.

For instance, from examples I see “interface.sendText(…” but what other options are there for the interface function and what are the arguments? I’ve been digging around for a while and I must be using the wrong search terms.

Any help would be much appreciated!

EDIT: Problem gelöst (siehe Kommentare), es war mal wieder 'ne Kleinigkeit: ein „and“, wo ein „or“ stehen sollte.

Liebe Menschen, die Dinge mit Python3 und Fotos machen: Gibt es einen Trick, die Größe eines Fotos zu ermitteln, das keine EXIF-Daten (oder andere Meta-Daten) hat?

Hintergrund: Ich möchte Fotos, die ich vorher gescannt habe, für einen bestimmten Zweck runterskalieren. Dazu verwende ich meinen downscaler (git.atari-frosch.de/?p=downsca). Der verläßt sich allerdings auf PIL, ergo auf vorhandene EXIF-Daten. Bei Scans hab ich die natürlich nicht.

downscaler meint, die Dateien seien schon zu klein, aber da muß ich nochmal nachschauen, warum das Fehlen der EXIF-Daten so interpretiert wird.