Multimedia

If you have previously only used PHP to work with HTML content, it will come as a nice surprise that working with multimedia content uses almost exactly the same process. It seems that many people just don't realise that PHP is capable of handling much more than non-HTML data, and hopefully this chapter will help shed a great deal of light on this exciting and challenging topic.

Through its extensions, PHP is able to easily handle creating image data in a variety of formats, generating Flash movies, and even generating PDFs - each have their own advantages and disadvantages, and are all in popular use. Having the ability to create custom multimedia content on the fly is very powerful indeed - although outputting content to HTML can do a lot, a picture says a thousand words! For example, by generating multimedia content, we can create dynamic weather forecasts, or user-customised PDFs - the possibilities are endless.

Note that in order to work with multimedia, you must first understand that each type of content, whether it be images, Flash, or PDF, all have their own unique file formats that need to be absolutely precise - you must be careful not to use any text in your multimedia PHP scripts, not even extra blank lines before or after your <?php and ?> tags. The RTF format allows text formatting to be contained using special text encoding characters, and therefore can be manipulated using simple string routines.

Topics covered in this chapter are:

  • The multimedia formats that are available and their advantages

  • Creating basic image formats

  • Working with the rich-text format (RTF)

  • Creating portable document format (PDF) files

  • Working with the Shockwave Flash (SWF) format

Chapter contents

  1. 11.1. Brief history of web media
    1. 11.1.1. GIF
    2. 11.1.2. PNG
    3. 11.1.3. JPEG
    4. 11.1.4. RTF
    5. 11.1.5. PDF
    6. 11.1.6. Flash
    7. 11.1.7. SVG
  2. 11.2. Images
    1. 11.2.1. Creating new images
    2. 11.2.2. Choosing a format
    3. 11.2.3. Getting arty
    4. 11.2.4. More shapes
    5. 11.2.5. Complex shapes
    6. 11.2.6. Outputting text
    7. 11.2.7. Loading existing images
    8. 11.2.8. Colour and image fills
    9. 11.2.9. Adding transparency
    10. 11.2.10. Using brushes
    11. 11.2.11. Basic image copying
    12. 11.2.12. Scaling and rotating
    13. 11.2.13. Points and lines
    14. 11.2.14. Updating the drawing script
    15. 11.2.15. Special effects using imagefilter()
    16. 11.2.16. Introduction to special effects using simple algorithms
    17. 11.2.17. Special FX, Colour reduction
    18. 11.2.18. Special FX, Interlacing
    19. 11.2.19. Special FX, Screen
    20. 11.2.20. Special FX, Greyscale
    21. 11.2.21. Special FX, Duotone
    22. 11.2.22. Special FX, Noise
    23. 11.2.23. Special FX, Scatter
    24. 11.2.24. Special FX, Pixelate
    25. 11.2.25. Special FX, Blur
    26. 11.2.26. Special FX, Other special effects
    27. 11.2.27. Interlacing an image
    28. 11.2.28. Getting an image's MIME type
    29. 11.2.29. Keeping your files small
    30. 11.2.30. Making graphs
  3. 11.3. Working with RTF
  4. 11.4. Creating PDF documents
    1. 11.4.1. There's more than one way to do it
    2. 11.4.2. Getting started
    3. 11.4.3. Adding more pages and more style
    4. 11.4.4. Adding imagery
    5. 11.4.5. PDF special effects
    6. 11.4.6. Adding document data
    7. 11.4.7. PDF Conclusion
    8. 11.4.8. Point sizes in real life
    9. 11.4.9. ClipPDF interoperability
    10. 11.4.10. PDF without a module?
  5. 11.5. Creating Flash
    1. 11.5.1. A simple movie
    2. 11.5.2. Flashy text
    3. 11.5.3. Actions
    4. 11.5.4. Animation
    5. 11.5.5. Flash Conclusion
  6. 11.6. Summary
  7. 11.7. Exercises
  8. 11.8. Further reading
  9. 11.9. Next chapter

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Brief history of web media >>

Previous chapter: Next chapter

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.