Skip to content

Instantly share code, notes, and snippets.

@nishadhka
Created June 4, 2017 07:18
Show Gist options
  • Save nishadhka/7d76f63c8ce6d49914a6f06e79fdc09d to your computer and use it in GitHub Desktop.
Save nishadhka/7d76f63c8ce6d49914a6f06e79fdc09d to your computer and use it in GitHub Desktop.
AccessingtheBasemapObject.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"editable": true,
"deletable": true
},
"cell_type": "markdown",
"source": "The image resizing has to be includes two thinks, image size and dpi, based on the dpi(resolution) the image size changes, so dpi has to be consider in image resizing, based on [this](https://stackoverflow.com/questions/273946/how-do-i-resize-an-image-using-pil-and-maintain-its-aspect-ratio) and [this](https://stackoverflow.com/questions/12609266/python-image-library-image-resolution-when-resizing) for getting the dpi info, the folowing commands does the image resize with exact reosltuoion and size. A 300 dpi image was needed so it is specified for a 200 dpi orginal image"
},
{
"metadata": {
"collapsed": true,
"editable": true,
"deletable": true,
"trusted": true
},
"cell_type": "code",
"source": "import PIL\nfrom PIL import Image\nbasewidth = 2340\nimg = Image.open('image.png')\ndpi = img.info['dpi']\nwpercent = (basewidth/float(img.size[0]))\nhsize = int((float(img.size[1])*float(wpercent)))\nimg = img.resize((basewidth,hsize), PIL.Image.ANTIALIAS)\nimg.save('image300.png]', dpi=(300,300)) ",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python2",
"display_name": "Python 2",
"language": "python"
},
"latex_envs": {
"eqNumInitial": 1,
"eqLabelWithNumbers": true,
"current_citInitial": 1,
"cite_by": "apalike",
"bibliofile": "biblio.bib",
"LaTeX_envs_menu_present": true,
"labels_anchors": false,
"latex_user_defs": false,
"user_envs_cfg": false,
"report_style_numbering": false,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
}
},
"language_info": {
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"name": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12",
"file_extension": ".py",
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
},
"gist": {
"id": "88c870083a621572cd7e4ecdd9a5a10b",
"data": {
"description": "AccessingtheBasemapObject.ipynb",
"public": true
}
},
"toc": {
"threshold": 4,
"number_sections": true,
"toc_cell": true,
"toc_window_display": true,
"toc_section_display": "block",
"sideBar": true,
"navigate_menu": true,
"moveMenuLeft": true,
"colors": {
"hover_highlight": "#DAA520",
"selected_highlight": "#FFD700",
"running_highlight": "#FF0000"
},
"nav_menu": {
"width": "252px",
"height": "31px"
}
},
"_draft": {
"nbviewer_url": "https://gist.github.com/88c870083a621572cd7e4ecdd9a5a10b"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment