Blog Archives

Draw dots in images using PHP, XMLHttp, Mysql.

A family member asked me if it was possible to use html, php, mysql to mark spots in an image of the human skeleton during an medical anamnesis collection. He wanted this to easily mark the complaint spots of his patients. He also needed to be able to remove marks when they where faulty and wanted this all to be stored in a database for easy reference and backup.

Seeing the complexity of it, I accepted the challenge he laid out for me.

The most complex part of this was the ‘how to remove’ spots from an image without deleting the actual fixed image of the skeleton. The solution I came up with was using an Fixed background image in HTML and use a transparent overlay that I will be updating using PHP and XMLHttp request headers.

The result of this approach was the following.

All that needs to be done during reporting is merging both images together, which is fairly easy using php.

But because I though someone else might use this script as well, I thought sharing it here with the world was a nice option. The application is endless, from damage reporting to Location reporting, and in the finished from its fairly easy to understand and adjust to your needs.

I added the sourcecode for this script to this post. You need to have a mysql database, php with GD enabled, browser that supports XHTMLRequest (all modern browsers). Simply dump the files into the a php html enabled location and make sure you create the required SQL table (usign the .sql script inside the archive) and have a go with it (you might need to alter the mysql user/pass inside the PHP script)….

image_draw-rar.pdf

Use the “save as” option to grab the file from this site. Rename the file to something.zip, unpack and access the srcfiles inside the rar archive… use winrar to unpack.

Let me know what you think, or if you found it usefull 🙂

p.s. I wasnt able to verify the author of the used skeleton image. If you are/know him, let me know if this application is allowed, and how to publish the credits.

Advertisements

Linux Filesystems what to know?

Here are some things that might help you out 🙂
There is much more to know about linux filessytems, but this might be a good start 🙂

hope this helps 🙂

# Some commands, they might come in handy 😉

############################################
df		        report file system disk space usage
df -h		        use the -h switch to display MBs instead of blocks.
df -i   	        show the free Inodes per file system
du		        estimate file space usage
du {file} -h	        use the -h switch to make the stats human readable.
tune2fs		adjust tunable filesystem parameters on ext2/3 filesystems.
tune2fs -l 	        show the actual filesystem superblock data {dev} should contain a SB.
e2label		Change the label on an ext2/3 filesystem
mkfs		        Build a linux file system
mke2fs		Build a Ext2 file system
mkisofs		Build a iso file system
mkudffs		Build a UDF file system
mkswap		Build a Swap file system
mkdosfs		Build a FAT File system
mkfs.vfat	        --
mkfs.msdos	        --
mount		Mount a linux filesystem
umount		Unmount a linux filesystem
swapon		Enable/disable devices and files for paging and swapping
swapoff		--
fsck		        Check a linux filesystem. (USE WITH CAUTION and RTFM FIRST!)
partprobe		inform the OS of partition table changes or list partitions on a device
parted		a partition manipulation program. A very strong but dangerious tool.
###########################################
# ALWAYS CONSULT THE MANPAGES BEFORE USING ANY
# OF THESE COMMANDS! KNOW WHAT THEY DO AND KNOW
# WHAT THEY WONT DO. SOME ARE DESTRUCTIVE WHEN USED
# INCORRECTLY!
###########################################

Linux devices
Next to these commands there is more to know about the linux filesystem. Most important aspect to know is how the fysical disks are made accessible. This is done by a process called mounting. When a linux OS boots it will probe for fysical attached disks and will create devices for each detected disk in the /dev/ directory. In some cases a device module (driver) is needed to be loaded into the kernel in order for it to access and probe the disk.

Depending on the device type a file (device) will be created in the /dev/ directory with a very specifik name. Here are some examples you might encounter in the /dev/ directory.

First MFM, RLL and IDE hard disk/CD-ROM interface
0 = /dev/hda		Master: whole disk (or CD-ROM)
64 = /dev/hdb		Slave: whole disk (or CD-ROM)

SCSI disk devices (0-15)
0 = /dev/sda		First SCSI disk whole disk
16 = /dev/sdb		Second SCSI disk whole disk
32 = /dev/sdc		Third SCSI disk whole disk

IBM iSeries virtual disk
0 = /dev/iseries/vda	First virtual disk, whole disk
8 = /dev/iseries/vdb	Second virtual disk, whole disk

For a full list check this site :)
http://www.kernel.org/pub/linux/docs/device-list/devices.txt

Linux Logical Volume management (LVM)
Linux also supports software raid. I wont be paying to much attention here because I allways advice people to use hardware raid instead. When you encounter “Volgroup##” inside the fstab you know an LVM group has been created. The LVM can be manipulated and verified using one of the following commands.

lvchange     lvdisplay    lvmchange    lvmsadc      lvreduce     lvresize
lvconvert    lvextend     lvmdiskscan  lvmsar       lvremove     lvs
lvcreate     lvm          lvmdump      lvm.static   lvrename     lvscan

please consult the manual for more details about these commands.

linux creating a filesystem and mounting
When a device is available in the devices directory you can actually start to use the device. One way of doing this is simply using the mount command stating, mount {device} {mountpoint}. But before doing this you need to decide what you want to do with the device. In most cases a filesystem will be created ontop of the device. For this task you can use the mkfs command or use parted to create partitions.

Please readup on the various filesystem types available. Commonly the Ext2 / Ext3 filesystems are used because they offer the best safety and manupilation options (ext3 doesnt support all the manipulation options ext2 supports). The following site is a good starting point when you are looking for more information on the subject.

http://www.yolinux.com/TUTORIALS/LinuxClustersAndFileSystems.html

Other options are mounting the disk without a filesystem in place a so called raw device, or use the device as swap space using swapon/off. Clustered filesystems are also an option but not described in this article.

Once you have decided how to use the disk, and the disk is available within linux (drivers etc) the next step would be making the disk available after boot. For this the fstab file is used. Simply add a new line with the correct parameters and the disk will be mounted at boot.

Some Important Files and their Locations.

/etc/fstab           Static Information about filesystems.  
/etc/mtab           Table of mounted filesystems
/etc/mtab~         Table of mounted filesystems lockfile
/etc/mtab.tmp     Temporary file
/etc/filesystems   A list of filesystems to try

Finaly, some tips while working with fylesystems.

TIP. Test the fstab file using the “mount -a” command before attempting a reboot. Best test is to unmount the disk prior to the mount -a command.

TIP. Also best practise is to modify disks, partitions, perform fsck`s in INIT 1. This will limit the ammount of running deamons dramaticly and will make your filesystem manipulation tasks much easier.

TIP. The mtab file will always list “devices” instead of “labels”. If you are wondering which device is used by a label try consulting the /etc/mtab.

TIP. In the /dev/ directory there might be a /disk/ directory. This directory will allow you to mount devices by the following attributes;
by-id,
by-label,
by-path,
by-uuid

This directory might come in handy when you are not sure what device was created by that usb disk you just plugged in. using the by-path for instance will show you de bus that is used by the various available disks, or by label that will show what label mappings exsist.
Always use the “ls -lart” command here to get the full details.

TIP. Be very carefull using the fsck command, it is well capable of destroying data on your disk if using incorrectly. Always read the manual fist using the manpages (man fsck).