Tag Archives: image

Exporting high resolution image from QGIS project



You want to export your QGIS project into high resolution image. QGIS desktop “Project” –> “Save as Image” only save/export the project into a low resolution image (i.e. your desktop resolution).



1. Finish your project in QGIS

Finish your GIS project in QGIS Desktop, choose which layers to be shown, what style should it use, etc.

2. Choose your extent that will be exported into image

For myself, I choose the full-extent, but you may choose the extent as you wish. You my use “Vector” –> “Coordinate Capture” to help copying the coordinates. You will need to write down the coordinates for [xMin, yMin] (top-left coordinate) and for [xMax, yMax] (bottom-right coordinate). Save and close your QGIS project.

3. Execute the export command via command line of QGIS

Open your command prompt/console (preferably as Administrator/root). Go to your QGIS binary folder, where you install QGIS +”bin” folder, for example C:\Program Files\QGIS Brighton\bin. Use this command template:

For example:

That command will open QGIS Desktop for a moment then close itself. The command will produce padangsari.png in c:\users\achmadz\documents\. Open the image, and you’ll see the image in high resolution (5000×5000 pixels).


Save bandwidth, block image hot linking

Image hot-linking is (simply put): other site is showing your image that still on your server. This can cause problem for bandwidth limited website, they steal your bandwidth! Also, this doesn’t make visitor from that notorious site to come to your site.  More visitor for them, more bandwidth lost for you. We will handle this issue using htaccess.

Remember that to use .htaccess fully (including this tips), you have to activate Apache mod_rewrite.

In our case, we will allow only few sites that directly show/link our image. Other sites that have no permission will show an error/no leech image. This is the full .htaccess code:


The explanation:

  • (line 1) Activate rule only if mod_rewrite is activated
  • (line 4) we don’t allow Facebook bot to steal our image. Comment (#) this line if you want to allow Facebook to grab image from your site (this is used by Facebook to create thumbnail image whenever FB users posting your website  URL)
  • (line 6-9) allow only few sites to direct link/hot link our image: ahowto.net, mp32u.net, google.com and bing.com
  • (line 10) don’t apply the rule for “no leech” image that will be served to bandwidth leecher/stealer. Don’t forget this line, or you’ll get forever loop that eventually stress your webserver.
  • (line 11) Serve the leecher with our error/no leech image. I suggest you to use more informative image, such as image that contain messages “visit my site to view the image”
example no_leech image

just an example that might annoy bandwidth stealer

Special case for Wordpress

Yes, I know that there are few “anti-leech/anti-hot-linkplugins out there, but make sure they have the correct htaccess code placement. Make sure the placement is before main wordpress htaccess default code. So, your wordpress blog htaccess code would be like this:


Preview and capture webcam into an axes

My first Matlab tips. We will create a GUI form that will preview and capture picture from webcam connected to your computer. Webcam preview and captured image will be shown on an axes.

  • Create a new blank GUI using Matlab’s GUIDE (File –> New –> GUI –> Blank GUI). Put one panel, two pushbutton and one axes. You can arrange them like this:
New form from Matlab's GUIDE

Arrange the component like this (just for example)

  • Tag the axes as axPreview, first pushbutton as pbPreview and second pushbutton as pbCapture.
  • When user click on pbPreview image form webcam will be shown on axPreview. pbCapture will capture the image, show it on axes and save it as an image file.
  • you need to know how’s Matlab detected your webcam. Open Image Acquisition Toolbox. From Matlab’s Command Window, type this: imaqtool  OR you can follow this screenshot to access it via Matlab’s start menu
matlab access imaqtool via menu

access imaqtool via start-menu

  • Make sure your webcam is connected in your computer before Matlab run! If not, Matlab might not detect your webcam
  • imaqtool window will be shown. See the screenshot (a part of imaqtool form):
matlab supported webcam mode

Matlab detected my webcam

  • From the screenshot, my webcam is detected as winvideo-1 and Matlab also lists all supported mode that my webcam has. I’ll use YUY2_176x144 mode (the 176×144 number is obviously the image size)
  • Put these codes on your pbPreview_Callback (it’s not quite pretty colored, GeSHi doesn’t support Matlab .m file language yet). Read the code’s comment for the explanation line by line

  • as for the pbCapture_Callback. Most of codes explanation are the same as pbPreview_Callback

  • Example result:
matlab preview and capture webcam

Example form running our Matlab codes

Things to remember:

  • connect your webcam before running Matlab
  • put a pause a few seconds before capturing image, without this you’ll capture black/dark image!
  • choose rgb as ReturnedColorspace before capturing image

UPDATE: since there are people that having difficulties implementing the code, you can download this .zip file so you can quickly try it on your own Matlab. (Please remember that this code is created using Matlab 2011a GUIDE, I don’t guarantee it will work on earlier version)

Download MATLAB demo codes to capture image from webcam

UPDATE 2 : In order to make the codes work on latest MATLAB you should make “vid” become a global variable. Here’s how:
on pbPreview_Callback, after preview(vid, hImage);, add these:

on pbCapture_Callback, replace vid = videoinput(‘winvideo’, 1, ‘YUY2_176x144’); with these:

Now it should work fine on latest MATLAB, tested on MATLAB 2015b.

Even slimmer WordPress Blog using WP Smush.it

In my previous post about enabling Gzip compression in your site via control panel, the trick will slimming down your wordpress blog size and eventually speeding up your site load time. Faster page load time means higher score in Page Speed and YSlow!

Here’s another step to make your wordpress blog slimmer: install WP Smush.it

After installing and activating the plugin, you can access it via wordpress menu “Media–>Library

This plugin will trimming down your image size based on Yahoo Smush.it technology. WP Smush.it will work on-the-fly when you are successfully uploading an image. Wp Smush.it also can work on-demand, means you can manually “smush” your images. By accessing menu “Media–>Library”, you can see how much space WP Smush.it save you per-image basis.

wp smush.it result

There’s a lot of saving in PNG image format (more than 20% saving) and basically below 10% saving for JPG image format (JPG format is already compressed and lossy, so, this is normal).

Reduce your image size on-the-fly, save hard disk space and gain faster page load time FOR FREE! How can you miss this offer.