50
loading...
This website collects cookies to deliver better user experience
pip install fimage
app.py
with:from fimage import FImage
from fimage.filters import Sepia
def main():
# replace 'my_picture.jpg' with the path to your image
image = FImage('my_picture.jpg')
# apply the Sepia filter to the image
image.apply(Sepia(90))
# save the image with the applied filter
image.save('my_picture_sepia.jpg')
if __name__ == "__main__":
main()
python app.py
app.py
to import more filters from FImagefrom fimage import FImage
from fimage.filters import Contrast, Brightness, Saturation
def main():
image = FImage('my_picture.jpg')
# apply the mutiple filters to the image
image.apply(
Saturation(20),
Contrast(25),
Brightness(15)
)
# save the image with the applied filter
image.save('my_picture_mixed.jpg')
if __name__ == "__main__":
main()
python app.py
apply
function matters, this is because the filters are applied sequentially, so the next filter will be applied over the resultant image from the previous one.app.py
one more time to use the Presetsfrom fimage import FImage
from fimage.presets import SinCity
def main():
# replace 'my_picture.jpg' with the path to your image
image = FImage('my_picture.jpg')
# apply the SinCity preset to the image
image.apply(SinCity())
# save the image with the applied preset
image.save('my_picture_sincity.jpg')
if __name__ == "__main__":
main()
Preset
Class and specifying these filters and their adjust values in it.app.py
let’s dofrom fimage import FImage
from fimage.presets import Preset
from fimage.filters import Contrast, Brightness, Saturation
# Create my custom preset and specify the filters to apply
class MyOwnPreset(Preset):
transformations = [
Contrast(30),
Saturation(50),
Brightness(10),
]
def main():
# replace 'my_picture.jpg' with the path to your image
image = FImage('my_picture.jpg')
# apply MyOwnPreset to the image
image.apply(MyOwnPreset())
# save the image with the applied preset
image.save('my_picture_custom.jpg')
if __name__ == "__main__":
main()
my_picture_custom.jpg