Skip to content

Instantly share code, notes, and snippets.

@sunnyone
Created October 10, 2014 16:03
Show Gist options
  • Save sunnyone/60e006b7642707c2e898 to your computer and use it in GitHub Desktop.
Save sunnyone/60e006b7642707c2e898 to your computer and use it in GitHub Desktop.
Scaling the image to 1/2 size
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from gimpfu import *
def plugin_main(img, layer):
width = img.width
height = img.height
resizedWidth = width / 2
resizedHeight = height / 2
name = ""
if img.filename:
name = os.path.basename(img.filename)
pdb.gimp_image_scale(img, resizedWidth, resizedHeight)
gimp.message(
"Original Size: %d,%d\n" % (width, height) +
"Resized Size: %d,%d\n\n" % (resizedWidth, resizedHeight) +
"CSS: \nwidth: %dpx;\nheight: %dpx;\n\n" % (resizedWidth, resizedHeight) +
"img: <img src=\"%s\" width=\"%d\" height=\"%d\" />" % (name, resizedWidth, resizedHeight)
)
register(
"python_fu_scale_half",
"Scale the image to the half size",
"Scale the image to the half size",
"Yoichi Imai",
"Yoichi Imai",
"2014",
"<Image>/Image/Scale to Half Size",
"*",
[],
[],
plugin_main)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment