Posts

Showing posts with the label photo

Mass resize photos in Linux with ffmpeg

To resize multiple photos at once, you can run this command line: + Resize To 1/10 its original size: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=iw*.1:ih*.1 "$filename";done with: iw: input width ih: input height + Keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=250:-1 "$filename";done

Update Moodle user's photo programmatically

In some cases, being able to update the moodle user's photo using command line instead of the web interface is pretty helpful. Here is the PHP snippet I wrote which will accomplish that: Notes: 1. The photo was name after the user's idnumber. You can use the username instead. 2. Need to run the script as root or sudo.

Django ImageField rename file on upload

By default Django keeps the original name of the uploaded file but more than likely you will want to rename it to something else (like the object's id). Luckily, with ImageField or FileField of Django forms, you can assign a callable function to the upload_to parameter to do the renaming. For example: from django.db import models from django.utils import timezone import os from uuid import uuid4 def path_and_rename (instance, filename):     upload_to = 'photos'     ext = filename.split('.')[-1]     # get filename     if instance.pk:         filename = '{}.{}'.format(instance.pk, ext)     else:         # set filename as random string         filename = '{}.{}'.format(uuid4().hex, ext)     # return the whole path to the file     return os.path.join(upload_to, filename) class CardInfo (models.Model):     id_number = models.CharFie...

Ex Machina drawing

Image
here

A photo

Image

Sweet memory

Image

Adding a transparent layer for a PNG image with GIMP

To enable transparent layer for a PNG image in GIMP, you need to add the Alpha Channel to that image: >> Layer (menu) >> Transparency >> Add Alpha Channel Move created layer to below the image and you can adjust, delete or modify parts of the original image to show the transparent background.