مساعدة:تحويل
تحويل مستند من صيغة إلى أخرى لكومنز يمكن أن يكون مفيدا من أجل جعل الوصول إلى المشتقات أسهل.
Converting PDF
- على الرغم من أن مستندات PDF مقبولة من قبل كومنز، إلا أنه من الصعب الوصول إليها.
Converting PDF to DJVU
See page Converting PDF to DjVu.
- التحويل إلى SVG:
- استخدم [$pdf2svg pdf2svg] (لينكس: [$pdf2svg-l pdf2svg]) للتحويل إلى SVG إذا كان يجب استخدام ملف PDF بأكمله كصورة، على سبيل المثال، إذا كان رسما بيانيا تم إنشاؤه بواسطة بعض البرامج.
Extracting text from PDF
- استخراج النص:
- إذا كان ملف PDF يحتوي على النص بشكل مقتطف بسهولة، فاستخدم إما GSview's "Edit" / "Text extract..." أو Adobe Acrobat viewer "Save كنص "، خلاف ذلك:
- اتبع النصيحة في "استخراج الصور" أعلاه، ثم اتبع النصيحة في "التحويل من صيغ الصور إلى النص" أدناه.
Converting DjVu
Converting DjVu to other formats is useful because someone might not have a DjVu viewer installed, and other formats can be readily viewed in browser.
Converting DjVu to PDF
See page Help:Converting DjVu to PDF
Converting DjVu to images
Use DjVuLibre command line utilities ddjvu (DjVu decoder) or djvups (to convert to PostScript).
Extracting text from DjVu
WinDjView can do that or DjVuLibre command line tool djvutxt.
Converting images
التحويل من صيغ الصور إلى GIF أو JPEG أو PNG أو TIFF
- استخدم ببرامج تجريبية (حرة للاستخدام الشخصي) IrfanView أو XnView وjpegcrop للتحويلات المتقدمة
- استخدم البرمجيات الحرة ImageMagick
Processing images obtained from scanner
Images obtained from scanner usually require some processing before making a PDF or DJVU out of them: cropping, turning, splitting, reducing the size, converting to TIFF etc. The open-source application ScanTailor-Universal is designed for this purpose. It can be downloaded from the project's releases page.
Creating PDF from images
- img2pdf, an open-source command line program, is designed to convert images losslessly to PDF. It can also set metadata (such as the title and author) and how the resulting PDF file should be presented by a PDF viewing program.
The following command will take all files in the current folder and convert them into a single PDF named test.pdf
with title and author metadata:
img2pdf --title "My First PDF" --author "Jack Example" --output test.pdf *
Note that this assumes the current directory does not contain non-image files or sub-folders. If all your source files are of a single type, such as JPEGs, you can specify *.jpg
as the input instead. You can also specify multiple input files individually.
See img2pdf --help
for everything img2pdf can do.
img2pdf is available from the Python Package Index and is also included in the repositories of many Linux distributions. A Windows executable is also available via the project's Appveyor.
- ImageMagick and GraphicsMagick can also be used to convert images to PDF files, if GhostScript is installed.
The following command will use ImageMagick's mogrify tool to convert all JPEG files to individual PDF files and place them in a subfolder named "pdf":
mogrify -format pdf -path pdf/ *.jpg
On some Linux distributions, the default ImageMagick security policy will block the program from handling PDF files. See this StackOverflow question for how to change the security policy.
Creating PDF from bitonal images
Bitonal images (ie. images that only contain a single shade of black and white) are a very efficient way of storing scanned documents that only contain text or other simple elements that only need two colors to be clearly represented. A high-quality bitonal text page is commonly only tens of kilobytes in size.
There are two bitonal compression methods used in PDF files, namely the CCITT Group 4 Fax compression and the JBIG2 compression. The latter is more efficient but has some perceived patent issues associated with it, resulting in JBIG2 encoding functionality often being missing or disabled in PDF creation software. However, it is sometimes possible to enable such functionality by installing the encoder yourself.
There are a number of tools for converting images to use bitonal compression. ScanTailor-Universal is an open-source tool for processing scanned pages that can output bitonal images. ImageMagick and GraphicsMagick are also able to do this with the -threshold
option.
The following ImageMagick command converts all .jpg files in a folder into bitonal TIF files using Group 4 compression and places them into a folder named "bitonal":
mogrify -format tif -compress Group4 -path bitonal/ -threshold 50% *.jpg
Play around with the value of -threshold
to find one that produces good results with your content.
JBIG2 conversion
OCRmyPDF is an open-source command line program mainly designed to add an OCR text layer to scanned PDF files. One of its additional features is its ability to optimize PDF files, which includes the conversion of other bitonal image formats to JBIG2. This requires the installation of the jbig2enc encoder. Compilation and installation instructions for Linux users are available here, and a third-party Windows executable is available here. The MacOS version packaged in Homebrew already includes jbig2enc.
See here for how to install OCRmyPDF on Windows. Many Linux distributions come with an OCRmyPDF package included in the repositories, though this may be outdated. OCRmyPDF is also available on pip.
The following command uses OCRmyPDF to add an OCR text layer to a PDF and arranges the PDF in a way that allows a web browser to start displaying it before it has been fully downloaded:
ocrmypdf --output-type pdf --fast-web-view 0 test.pdf test-OCR.pdf
OCRmyPDF by default losslessly optimizes the PDF, so bitonal images are automatically converted to JBIG2 if jbig2enc is installed.
If you want to skip the OCR process because you don't need to OCR the PDF, use --tesseract-timeout 0
to skip OCR altogether.
See OCRmyPDF's documentation for further usage examples.
Creating DjVu from images
Use DjVuLibre command line tools c44 (for color images) and cjb2 (for bitonal images) to convert images to single-page DjVu files, then join them with djvm.
Example c44 command line:
c44 [options] pnm-or-jpeg-file [djvufile]
The important options are -slice, -dpi and -mask. -slice sets the number of "slices" in each "chuck" (which are some tricky DjVu terms). Giving three numbers means there will be three "chunks", and four numbers will result in four chunks. These numbers seriously affect quality and size - experiment and check the documentation.
c44 -slice -slice 74+13+10 -dpi 150 pnm-or-jpeg-file [djvufile]
From the cjb2 bitonal encoder's self-explaining help:
Usage: cjb2 [options] <input-pbm-or-tiff> <output-djvu> Options are: -verbose Display additional messages. -dpi <n> Specify image resolution (default 300). -clean Cleanup image by removing small flyspecks. -lossy Lossy compression (implies -clean as well) -losslevel <n> Loss factor (implies -lossy, default 100) Encoding is lossless unless a lossy options is selected.
In many cases, -losslevel can be harmlessly set as low as 50.
For details, see DjVuLibre documentation.
Minidjvu allows to convert black & white single-page and multi-page TIFF, BMP and PBM to DjVu and reverse. It has a simple graphical shell. Its support for multi-page TIFF files is a notable advantage over DjVuLibre tools.
minidjvu 0.8 - encode/decode bitonal DjVu files Usage: single page encoding/decoding: minidjvu [options] <input file> <output file> multiple pages encoding: minidjvu [options] <input file> ... <output file> Formats supported: DjVu (single-page bitonal), PBM, Windows BMP, TIFF. Options: -A, --Averaging: compute "average" representatives -a <n>, --aggression <n>: set aggression level (default 100) -c, --clean remove small black pieces -d <n> --dpi <n>: set resolution in dots per inch -e, --erosion sacrifice quality to gain in size -i, --indirect: generate an indirect multipage document -l, --lossy: use all lossy options (-s -c -m -e -A) -m, --match: match and substitute patterns -n, --no-prototypes: do not search for prototypes -p <n>, --pages-per-dict <n>: pages per dictionary (default 10) -r, --report: report multipage coding progress -s, --smooth: remove some badly looking pixels
- DjVuSolo has the ability to create DjVu files.
- Some advanced scripts are available to do the job.
التحويل من صيغ الصور إلى النص
gImageReader
- gImageReader is an open-source application for extracting text from images and image-based PDF documents. It's able to automatically detect the layout of text and post-process the recognized text, including spell checking and removal of line breaks. It uses Tesseract for text recognition, and as such it supports any language that Tesseract does.
IrfanView
- استخدم برنامج خيار القائمة المساعد "ابدأ OCR" (OCR هو التعرف الضوئي على الرموز) لاستخراج النص، اعتبارا من 2010-02-20 يقتصر البرنامج المساعد KADMOS OCR لـIrfanview على حوالي ست صفحات اعتمادا على الذاكرة الخالية للحاسوب (حوالي 1 غيغابايت لكل 10 صفحات)، قد تحتاج إلى التحويل في أقسام، ستحتاج إلى تصحيح النص الذي تم إنشاؤه يدويا لأن التحويل غير مثالي.
Pdf X-Change Viewer
- Use PDF-XChange Viewer's OCR function: Document -> OCR pages.
Tesseract engine
- أو استخدم البرنامج الحر مفتوح المصدر tesseract (لينكس أو ماك أو إس أو ويندوز):
- نزل كلا من برنامج "tesseract" وحزم اللغات "tessdata" ذات الصلة باللغات التي تظهر في المستند الممسوح ضوئيا، وفكها في نفس المجلد، ليست هناك حاجة إلى تثبيت لويندوز قابل للتنفيذ
- احصل على أعلى دقة مسح ممكنة، وإذا لزم الأمر قم بزيادة توسيع صورة المسح الضوئي (استخدم تغيير حجم سريعا، وتجنب مرشحات إعادة الصياغة) حتى تكون الأحرف أكثر من 20 بكسل (جرب للحصول على أفضل النتائج) واحفظه كملف TIFF غير مضغوط (استخدم ImageMagick أو IrfanView)، ستحتاج إلى الكثير من مساحة القرص
- جرب أجزاء صغيرة أولا لأن التعرف يمكن أن يستغرق عدة دقائق لكل صفحة
- tesseract قد يتلف مع أجزاء الإدخال أكبر من حوالي 12 صفحة
- استخدم الأمر "tesseract.exe input.tif output"
eScriptorium
- Use the free Open Source software eScriptorium with Kraken. The server component can be installed on Linux, macOS or Windows (with WSL). The client side is a web application which works in any modern web browser. It allows segmentation of text regions and lines and recognition of printed text and handwriting. Both segmentation and recognition can be trained.
Google has OCR. See:
In all cases, you may need to convert in sections. You will need to manually correct the generated text because the conversion is not perfect.
Converting video
Further help
You can ask for help at the Commons:Help desk.