Writing programs which create image files. We have seen that an image file just contains a sequence of bytes –We know, in detail, the rules that apply.

Slides:



Advertisements
Similar presentations
LIS651 lecture 5 direct use of wotan Thomas Krichel
Advertisements

KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
BMP Hide ‘n’ Seek What is BMP Hide ‘n’ Seek ? –It’s a tool that lets you hide text messages in BMP files without much visible change in the picture. –Change.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Linux File & Folder permissions. File Permissions In Ubuntu, files and folders can be set up so that only specific users can view, modify, or run them.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
UNIX And other sundry items. UNIX Unified account is your UNIX account or it can be first initial, first name, number, and then part of last name Also.
File Security. Viewing Permissions ls –l Permission Values.
File security and Permissions A file is owned by the user who created it That user can then specify who can read, write and execute that file A file when.
Using a hex editor to edit an image We can actually use hex editors to change image files Usually, we will use programs like PhotoPlus or PhotoShop But.
Different Streaming Technologies. Three major streaming technologies include:
Higher-level PHP constructs for manipulating image files.
A 24-bit depth.bmp file made in XVI32 This 2-by-2 image was handcrafted in XVI32 Bytes 1C-1D hex in the Info Header say that the image uses 24-bit (18.
By Rashid Khan Lesson 8-Crowd Control: Controlling Access to Resources Using Groups.
How pictures are stored in computers. While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures.
UNIX By Darcy Tatlock. 1. Successful Log Into Unix To actively manipulate your website you need to be logged in. Without being logged in you cannot enter.
Copyright © 2014 EMC Corporation. All Rights Reserved. Exporting NFS File Systems to UNIX/ESXi Upon completion of this module, you should be able to: Export.
Accessing the Internet with Anonymous FTP Transferring Files from Remote Computers.
Eucalyptus Virtual Machines Running Maven, Tomcat, and Mysql.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Command Line Unix for Information Professionals In web administration or information management work, I may be called upon, as an Information Professional,
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
Department of Information Technology Chapter 8 - Creating Hypertext links Lecturer: Ms Melinda Chung.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
HTML Hyper Text Markup Language A simple introduction.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
ECT 250: Survey of E-Commerce Technology FrontPage Publishing pages Unix.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
Unit 2, cont. September 12 More HTML. Attributes Some tags are modifiable with attributes This changes the way a tag behaves Modifying a tag requires.
File Permission and Access. Module 6 File Permission and Access ♦ Introduction Linux is a multi-user system where users can assign different access permission.
Linux Operations and Administration
Web Design (7) Images (1). Images and the Image Element Images can be placed in the flow of text..jpg,.png and.gif image files work in web pages The img.
Chapter 3 Some additional notes… File permissions A file has three types of permissions (read, write and execute). Available to three categories of users.
Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.
8-2 What is a program? What is a “Window Manager” ? What is a “GUI” ? How do you navigate the Unix directory tree? What is a wildcard? Readings: See CCSO’s.
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
CS 346 – Chapter 11 File system –Files –Access –Directories –Mounting –Sharing –Protection.
BASIC FILE ATTRIBUTES. CONTENTS ls –l to display file attributes (properties) Listing of a specific directory Ownership and group ownership Different.
HTML HyperText Markup Language. Text Files An array of bytes stored on disk Each element of the array is a text character A text editor is a user program.
File Systems, telnet and ftp Sources and Resources: 1. A Students Guide to UNIX, by Hahn 2. Paula Davidson’s Handout on UNIXHandout on UNIX.
Revision: Absolute and relative paths. (root) staffusrbinstudetc ResearchTeachingPrivate pgugitmasters xxxgtrxxx CUA Coursework1.txt CUA xxx02uxxx04u.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
File Uploads. The Form tag Set the method to “post” The form attribute enctype="multipart/form- data” must be in the opening form tag Before the file.
HTML Hyper Text Markup Language. The Basics u HTML documents contain “tags” which instruct the Browser software on how to present the information within.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
BIF703 File Permissions. As you recall from our previous notes, that Unix/Linux recognizes everything as a file: Regular files to store data, programs,
Lecture 8 Introduction to Web Programming. Announcement  First In-class exam will be on Oct. 10 (Wednesday)  2.50pm – 4.05pm  Exam will cover all materials.
User Manual for Tmaptool – T1 ρ processing tool Guruprasad Krishnamoorthy Chetana Bayas Gargi Pednekar.
+ Introduction to Unix Joey Azofeifa Dowell Lab Short Read Class Day 2 (Slides inspired by David Knox)
Solvency II Tripartite template V2 and V3 Presentation of the conversion tools proposed by FundsXML France.
Login Being logged into a command line prompt allows a user to easily and simply execute multiple commands (one-by-one or at the same time) that would.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Pre-Production Meet with the client to create a project plan:
Navigating the Filing System
How to change the LOGO on PecStarWeb V3.6
Web Interface for Formatter
Unix Commands PowerPoint
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
BIF703 File Permissions.
Intro to PHP & Variables
INSTALLING AND SETTING UP APACHE2 IN A LINUX ENVIRONMENT
FTP and UNIX TOPICS Exploring your Web Hosting Site FTP UNIX
Permission and CHMOD.
Configuring Internet-related services
Lab 2: Terminal Basics.
Figure 6-13: Managing Permissions
Presentation transcript:

Writing programs which create image files

We have seen that an image file just contains a sequence of bytes –We know, in detail, the rules that apply to the sequence of bytes in a BMP file Most programming languages allow us to create new files and to write data into such files PHP is one such programming language We will use it to create some image files

Creating image files with PHP An example PHP program which writes two bytes of data, 42 hex and 4D hex, into a file called file1 <?php $fp=fopen(“file1”,”w”); $byte=chr(0x42); fwrite($fp,$byte); $byte=chr(0x4D); fwrite($fp,$byte); fclose($fp); ?>

Folder before this program is executed

Browser window when this program is executed

Folder after this program is executed The file called file1 has not been created Why not? Because the web server (which executes the PHP program) does not have permission to write into the folder /j.bowen/cs1107/exercises/tests/demo

Unix/Linux Permissions The computer on which the web server runs uses Unix Log in and view the folder Using the command ls –l we can see detailed information about the program demo.php The permissions associated with demo.php are -rw-r--r--

Unix/Linux Permissions (contd.) The set of possible permissions that a file or directory (folder) can have is drwxrwxrwx The first position contains d if and only if the item is a directory (folder) so the hyphen in the first position of the demo.php permission confirms that demo.php is a file, not a folder The other positions come in groups of three -rwxrwxrwx

Unix/Linux Permissions (contd.) The permissions come in sets of three -rwxrwxrwx The first set specifies whether the user who owns the item can read, write or execute the item The second set specifies whether the group to which the owning user belongs can read, write or execute the item The third set specifies whether other users can read, write or execute the item The permissions associated with demo.php are -rw-r--r-- –So the user who owns demo.php can read and write the file; but the group and others can only read it.

Permissions for /j.bowen/cs1107/exercises/tests/demo Use the cd.. command to go up to the parent directory Using the command ls –l we can see detailed information about the contents of the parent directory The permissions associated with our target folder are drwxr-xr-x So only the user can write into the target folder

Permissions for /j.bowen/cs1107/exercises/tests/demo Use the chmod g+w command to let the group write into the folder chmod g+w demo Using the command ls –l we can see that the permissions associated with our target folder are now drwxrwxr-x So the user and his group can write into the target folder

Permissions for /j.bowen/cs1107/exercises/tests/demo The permissions associated with our target folder are now drwxrwxr-x The web server (which runs PHP programs) is part of each user’s group –so a program controlled by the web server can now write into the target folder So, let’s execute our program again and see what happens

Folder before this program is executed

Browser window when this program is executed

Folder after this program is executed The file called file1 has been created

Let’s inspect the file with XVI32 Right-click on the file and download it Then, …

Let’s inspect the file with XVI32 … then open the file with XVI32 We see that the contents are as expected <?php $fp=fopen(“file1”,”w”); $byte=chr(0x42); fwrite($fp,$byte); $byte=chr(0x4D); fwrite($fp,$byte); fclose($fp); ?>

We can use PHP to create BMP files We have just seen that we can use PHP to write arbitrary bytes into a file Therefore, we can use PHP to create BMP files For example, we can easily create a BMP file by following the rules we saw earlier for the absolutely basic 24-bit depth BMP format

Absolutely basic 24-bit depth BMP format The minimum we must do when making a 24-bit depth BMP file is –assign the fixed values shown below to the bytes marked green –put the image width and depth in bytes hex and hex, respectively –specify the pixels from byte 36 hex onwards, 3 bytes per pixel, padding the lines if necessary to make each line a multiple of four bytes –put the overall file size in bytes hex

PHP program to create a 24-bit depth BMP file (part 1) <?php $fp=fopen("file2.bmp","w"); $byte=chr(0x42); fwrite($fp,$byte); $byte=chr(0x4D); fwrite($fp,$byte); // The next four bytes give the file size $byte=chr(0x66); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); $byte=chr(0x36); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); $byte=chr(0x28); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte);

Creating a 24-bit depth BMP file (part 1, abbreviated) <?php $fp=fopen("file2.bmp","w"); $byte=chr(0x42); fwrite($fp,$byte); $byte=chr(0x4D); fwrite($fp,$byte); // The next four bytes give the file size $byte=chr(0x66); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0x36); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0x28); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 2) fwrite($fp,$byte); // The next four bytes give the width $byte=chr(0x04); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); // The next four bytes give the height $byte=chr(0x04); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0x01); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); $byte=chr(0x18); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 3) fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 4) fwrite($fp,$byte); //The pixel data start here $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 5) $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 6) fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte); $byte=chr(0x00); fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF); fwrite($fp,$byte);

PHP program to create a 24-bit depth BMP file (part 7) $byte=chr(0x00);fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF);fwrite($fp,$byte); $byte=chr(0x00);fwrite($fp,$byte); fwrite($fp,$byte); $byte=chr(0xFF);fwrite($fp,$byte); fclose($fp); ?>

Folder before this program is executed

Browser window when this program is executed

Folder after this program is executed The file called file2.bmp has been created Let’s open it in the browser …

Browser window when file2.bmp is opened Let’s zoom in …

Browser window when zoom level is 400%

Higher-level PHP constructs for manipulating image files We know how to create image files by specifying individual bytes But this is very tedious PHP provides higher-level constructs for creating and/or editing image files We will look at these in the next set of slides