Wednesday, November 07, 2012

Mac OS X Preview reduce PDF size

Problem:

I have some (scanned) PDF documents which is a bit large (in a few MB) and want to reduce their size. The Preview app in Mas OS X has the function to reduce the PDF size but the resulted output is not clear enough to be useful.

To reduce PDF size in this way, we first open the PDF file in Preview. The select "File" -> "Export...". In the "Quartz Filter" option, select "Reduce File Size" and then "Save" the file with a new name. In one example, a 1.4MB colour scanned file is reduced to 65KB but the text is hardly readable.


Configuration:

Mac OS X 10.8.2


Solution: 

Open the "ColorSync Utility" from the "Applications" -> "Utilities" folder. On the lower left corner, click the "+" icon to add a new filter. You can name it as "PDF downsize".

Select this new filter and click the down arrow icon on the right. Select "Add Image Effects Component" -> "Color Image Sampling". In the newly created "Image Sampling" component, set the followings:

Scale : 100%
Resolution : <empty> Pixels / inch
Max : 1684 Pixels
Min : 512 Pixels
Quality : High

Click the down arrow icon again, this time, select "Add Image Effects Component" -> "Image Compression". In the newly created "Image Compression" component, set the followings:

Mode : JPEG
Quality : slide to around 25% towards Min

After these modifications, the "ColorSync Utility" can be closed.

Finally, open a terminal window (by "Applications" -> "Utilities" -> "Terminal". Then run the following command. Enter you root password if asked.

sudo mv ~/Library/Filters/PDF\ downsize.qfilter  /Library/PDF\ Services/

Now, you can select the "PDF downsize" filter in Preview and the above mentioned example is reduced from 1.4MB to 353KB with very readable result.

Tuesday, November 06, 2012

Disable auto generation of ~/Desktop ~/Documents ~/Downloads etc.

I prefer mwm and don't want any of the Gnome/KDE stuff on my (CentOS 6.3) desktop. But the system keep regenerating the following folders in my home directory.

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

Solution:

Edith /etc/xdg/user-dirs.conf to set "enabled=False". Then remove the above directories and relogin again. Done!

Saturday, November 03, 2012

Problem of X11 forwarding

Problem:

When connected using the -X or -Y option with ssh, the following error is reported.

/usr/bin/xauth:  timeout in locking authority file /home/<user>/.Xauthority


Cause:

It is in fact caused by incorrect SELinux setting.


Solution:


# ls -alZ
drwxr-xr-x. uid gid   unconfined_u:object_r:home_root_t:s0 <user>
# chcon unconfined_u:object_r:user_home_t:s0 <user>
# ls -alZ
drwxr-xr-x. uid vid   unconfined_u:object_r:user_home_t:s0 <user>

Then login again, the xauth will create the .Xauthority automatically.