PHP Classes

PHP DOCX to Image: Extract images from Microsoft Word DOCX files

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 145 All time: 9,143 This week: 47Up
Version License PHP version Categories
docxtoimg 1.0.0GNU General Publi...5PHP 5, Graphics, Files and Folders
Description 

Author

This class can extract image files from Microsoft Word DOCX files.

It can take the path of a Microsoft Word file in DOCX format and extract its contents to save the image files that it contains.

The extracted images files are saved to a given directory.

Innovation Award
PHP Programming Innovation award nominee
October 2021
Number 5
Microsoft Word is a popular tool used by many people to create documents that may contain text, images, charts, and other types of data.

Often Microsoft Word users share their documents as files in DOCX format.

This class provides a simple solution to parse Microsoft Word files in DOCX format and extract the images that contain them into files that any PHP application can quickly process.

Manuel Lemos
Picture of Timothy Edwards
  Performance   Level  
Name: Timothy Edwards <contact>
Classes: 4 packages by
Country: United Kingdom
Age: ???
All time rank: 2973136 in United Kingdom
Week rank: 44 Up3 in United Kingdom Up
Innovation award
Innovation award
Nominee: 2x

Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

</head>

<body>
<?php
require_once('wordimg.php');
$rt = new WordPHP(true);
$rt->readDocument('sample.docx');
?>
</body>


Details

A php class to extract all the images from a Word DOCX document and save them as separate image files

Description

This php class will take a DOCX type Word document and extract all the images that are contined in it. They will be then all be saved in a directory with the same name as the original DOCX file. This directory will be automatically created if it does not exist. In the normal mode this class will not provide any output to screen. A php demonstration file (imgtest.php) is included. This demonstration file expects the DOCX file to be named 'sample.docx'.

USAGE

Normal mode to save all the images (no output to screen)

$rt = new WordPHP(false); or $rt = new WordPHP();

Display on screen the names of the images found and saved

$rt = new WordPHP(true);

Read docx file and save all the images found

$rt->readDocument('FILENAME');

  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file imgtest.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file wordimg.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:145
This week:0
All time:9,143
This week:47Up