I need to upload images and get Exif to display.
I'm using exif_read_data to get exifs data.
$data = exif_read_data($imageFile, 'EXIF', true);
Everything is fine, but :
$data['EXIF']['ExposureProgram'] = 3
I know Exposure Programm could be :
aperture priority
shutter priority
auto
manuel
I don't find any information about this number and what is its meaning.
Maybe someone can help me here ?
Thanks
Why not checking Exif's Standard 2.32 itself? Page 50:
0 = Not defined
1 = Manual
2 = Normal program
3 = Aperture priority
4 = Shutter priority
5 = Creative program (biased toward depth of field)
6 = Action program (biased toward fast shutter speed)
7 = Portrait mode (for closeup photos with the background out of focus)
8 = Landscape mode (for landscape photos with the background in focus)
Other = reserved
Phil Harvey's ExifTool reference is also worth to check for additional improper values from vendors violating the standard(s):
(the value of 9 is not standard EXIF, but is used by the Canon EOS 7D)
9 = Bulb
Related
I'm using a simple PHP script to recognize handwritings in death certificates. With words it works quite well, but with numbers no.
The result I get with my simple PHP code with DOCUMENT_TEXT_DETECTION, is the same as with the "Try it!" Google demo page.
This is an example of the result:
enter image description here
And this is the piece of PHP test code:
require "/var/www/vendor/autoload.php";
use Google\Cloud\Vision\VisionClient;
$vision = new VisionClient(['keyFile'=>json_decode(file_get_contents("*******.json"),true)]);
$image = fopen($imageName,'r');
$imageProcessed = $vision->image($image ,['DOCUMENT_TEXT_DETECTION']);
$result = $vision->annotate($imageProcessed);
As you can see from the result image, it's seems that it rotates the image of 180° so that "08 01 1929" (birth date in "dd mm yyyy" format) rotated resemble "616r r0 80". 9 becames 6, 2 becomes 1, and 1 becomes r.
How can I fix the problem? Can I hint the algorithm from the code that these are numbers and to not rotate the image?
Thank you in advance!
Valerio
I've been able to get EXIF data by using exif_read_data(). According to the EXIF documentation provided on PHP docs, there has to be an imageNumber tag (I understand it's not guaranteed), but I haven't been able to see anything like that on my test image (Unedited JPG from a Nikon D5100). The same image seems to carry information about the shutter count as per online shutter count websites.
Really appreciate it if you can shed some light on what I'm possibly doing wrong to get this number. Or is there any other place or method they store shutter count in image meta?
EDIT:
Here's the code I tried to work out, and I'm trying to get imageNumber which is apparently not available to get. But online tools show the shutter count on the same image. I'd like to get the same result using PHP (or even using another language). Any help is appreciated.
$exif_data = exif_read_data ( $_FILES['fileToUpload']['tmp_name']);
print_r( $exif_data);
As per your example file it is specific to Nikon's MakerNote and in there specific to the D5100 model. Using ExifTool in verbose mode shows the structure:
> exiftool -v DSC_8725.JPG
...
JPEG APP1 (65532 bytes):
ExifByteOrder = MM
+ [IFD0 directory with 11 entries]
| 0) Make = NIKON CORPORATION
| 1) Model = NIKON D5100
...
| 9) ExifOffset (SubDirectory) -->
| + [ExifIFD directory with 41 entries]
...
| | 16) MakerNoteNikon (SubDirectory) -->
| | + [MakerNotes directory with 55 entries]
...
| | | 38) ShotInfoD5100 (SubDirectory) -->
| | | + [BinaryData directory, 8902 bytes]
...
| | | | ShutterCount = 41520
JPEG explained, see segment APP1:
Exif explained, see tag 0x927c:
Nikon's MakerNote explained, see tag 0x0091:
ShotInfoD5100 explained, see index 801
MakerNotes are proprietary: how data is stored there is up to each manufacturer. Documentations from those are rare - mostly hobbyists reverse engineer that information - that's why only selected software can read it at all for selected models. At this point you may realize that dozens of manufacturers with dozens of models exist, for which you all would have to interpret bytes differently - which is a lot of work! As per exif_read_data()s ChangeLog PHP 7.2.0 nowhere claims to support Nikon at all.
You have to either parse the MakerNote yourself or find PHP code/library/software which already did that for you. As a last resort you could execute non-PHP software (such as ExifTool) to get what you want.
Is there any way to set a LinePlot->SetFillColor to go upwards instead of going down in JPGraph - PHP?
$p6 = new LinePlot($arrayLimSpecI);
$graph->Add($p6);
$p6->SetColor("#0B610B");
$p6->SetWeight(3);
$p6->SetStyle("solid");
//FillColor Fills the plotline from point 0 to point X
$p6->SetFillColor('red#0.65');
What I've tried:
$band = new PlotBand(HORIZONTAL,BAND_SOLID,$valueS,"max",'red');
$band->ShowFrame(false);
$graph->AddBand($band);
But this band doesn't seem to adjust to the dynamic marks that the graphic has got. If I set valueS to show on Y-Mark 10 it will show instead on the mark point 40.
EDIT: Another library that is currently supported or is capable or doing this is welcomed.
I have got a .doc file with english and chinese text in it, they are descriptions for products.. they are split apart in the doc by numbers i.e. 0001,0002,0003,0004,0005 etc etc
For example..
0001
技术参数
电压:AC90V-120V/220V-240V 50-60HZ
功率:400W
光源:120PCS 1W/3W LEDS
(R:30pcs,G:30pcs,B:30psc,W:30pcs)
控制通道:12通道
运行模式:主从,自走,声控,DMX512
每颗LED的理论寿命为50000-100000时
光学透镜角度标准15度
水平扫描:540度,垂直扫描270度
可以调节扫描速度
无限的RGBW颜色混色系统
显示操作面板彩用LCD显示屏
产品尺寸:515*402*555mm
净重:19kg 毛重:21kg
TECHNICAL PARAMETER
Voltage: AC90V-120V or 200V-240V 50-60HZ
Power consumption:400W
Light source:120PCS 1W or 3W LED
(R:30pcs,G:30pcs,B:30psc,W:30pcs)
Control mode:12HS
Operation mode: master-slave, auto movement,
Sound control: DMX 512
Each led source has an expectancy over 50000 to 100000 hours in theory
Optical len angle:15 degrees
Level scanning:540 degrees Vertical scanning
270 degrees, speed adjustable
Indefinite RGBW color mixing system
LCD display adopted
Product size:512*402*555mm
N.W:19kg G.W:21kg
0002
技术参数
电压:AC100V-240V,50/60HZ
功率:360W
光源:108颗 1/3W LED
运行模式:主从,自走,声控,DMX512
控制通道:11通道
水平扫描:540度,垂直扫描270度
高度电子调光,频闪可达1-20次/秒
均匀的RGB混色系统和彩虹效果(可加白色)
光斑角度:15度
包装尺寸:420*330*550mm
净重:10kg 毛重:13kg
TECHNICAL PARAMETER
Voltage:AC100V-240V ,50/60HZ
Power consumption:306W
Light source:108pcs of 1/3W LED
Operation mode master-slave, sound control,
auto movement,DMX512
Control channel:11Hs
Level scanning angle:540 degrees
Vertical scanning angle:270degrees
Quick electronic dimmer, strobe from 1 to 20 times/second
Smooth RGB mixing system &
Rainbow effect(can add white)
Beam angle:15 degrees
Package size :420*330*550mm
N.W:10kg G.W:13kg
0003
技术参数
电压:AC90V-120V,200V-250V,50/60HZ
光束角:10度,15度,25度可选。
控制通道:11通道
预期使用寿命:50000小时
最低的能量消耗。
信号控制:12个标准DMX 12通道控制,独立的主从控制。
频闪:1-18次/秒
LED显示。
内置程序:内置的8个程序能被DMX控制激活。
尺寸:307*354*267mm
净重:8.7kg
符合GB7000.1-2007.GB7000.217-2008及CE标准
TECHNICAL PARAMETER
Power supply:AC100V-120V.200V-250V.50/60Hz
Angle of light beam:10。15。
25。 Are available for choice.
Control channel:11
Service life:50000 hours
The lowest power consumption
Control signal 12 Standard DMX controlling
Channels and ant channels combination
Can be sep up.
Independent master/slave control
Strobe:1-18 flash per second
Inside program: the 8 inside program can
be activated by DMX controller
Dimensions:307*354*267mm
N.W:8.7kg
Up to CE standard. UL standard and
GB 7000.15-2000standard
Any ideas of which best way to split it and put in to a database ?
Thanks
Lee
1. mb_split is for multibyte strings not preg_split
Use mb_split() (linked to man page):
$descriptions = mb_split("/\d{4}/", $text);
2. Loop through the file
Another method of attack that possibly avoids non-multibyte safe PHP functions being run on the text and mucking up the Chinese portions:
$file = file('/file/path');
$descriptions = array();
$description_counter = 0;
foreach($file as $line) {
$line = trim($line);
if(preg_match("/^\d{4}$/", $line)) {
$description_counter++;
}
$descriptions[$description_counter] .= $line . "\n";
}
print_r($descriptions);
Copy text in $text and use
$r = preg_split("(\n\d{4}\n)", $text);
PHP and GD seem to have trouble creating images from PNGs of type greyscale with alpha when using imagecreatefrompng(). The results are incredibly distorted.
I was wondering if anyone knew of a way to test for the colour type in order to notify the user of the incompatibility?
Example:
Original Image: http://dl.dropbox.com/u/246391/Robin.png
Resulting Image: http://dl.dropbox.com/u/246391/Robin_result.png
Code:
<?php
$resource = imagecreatefrompng('./Robin.png');
header('Content-type: image/png');
imagepng($resource);
imagedestroy($resource);
Cheers,
Aron
The colour type of a PNG image is stored at byte offset 25 in the file (counting from 0). So if you can get hold of the actual bytes of the PNG file, simply look at byte 25 (I don't do PHP, so I don't know how to do that):
0 - greyscale
2 - RGB
3 - RGB with palette
4 - greyscale + alpha
6 - RGB + alpha
The preceding byte (offset 24) gives the number of bits per channel. See the PNG spec for more details.
In a slight twist a PNG file may have "1-bit alpha" (like GIFs) by having a tRNS chunk (when it is colour type 0 2 or 3).
i landed here today searching for a way to tell (via php) if a specific .png image is an alpha-png one -
David Jones' answer points to the right direction, really easy to implement in php:
file_get_contents to load just that 25' byte (there it is, indeed!), and
ord() to get its ASCII value, to test it (against '6' in my case)
if(ord(file_get_contents($alpha_png_candidate, NULL, NULL, 25, 1)) == 6) {
is_alpha_png_so_do_something();
}
actually i needed that for assuring backward compatibility with ie6
within cms-user-generated-pages, to replace all alpha-png < img > tags with inline-block < spans > - the alpha-png file will then be served as variable for the ms-proprietary css property filter
.alpha_png_span{
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
src='$alpha_png_candidate', sizingMethod='crop')
}
...and it all works, so thanks!
paolo
see this answer
:
Another usefull note for those using ImageCreateFromPng:
PHP and GD do not recognize grayscale/alpha images.
So if you use grayscale images with transparency between 0% and 100%, then save the image as RGB.
At least this is true for PHP Version 4.4.2-1 and in 5.1.2-1 with pictures made with GIMP 2.2.8.
url :
http://php.net/manual/en/function.imagecreatefrompng.php