旅の写真〜騎兵第二十六連隊跡





2015/09/23 愛知県豊橋市にある、騎兵第二十六連隊跡の碑を見に行った際の写真です。

記者の祖父が所属していた部隊で、長年行きたかったのでやっと行けました。



住宅地とスーパーの間の小さい公園の半分を占めた、こじんまりとしたものですが、

きちんと清掃されており、地域住民の方の憩いの場兼防災拠点となっているようです。



この碑の詳細はこちらのページにもあります。
http://www.geocities.jp/bane2161/kihei26rentai.html


場所:〒441-8066 愛知県豊橋市王ケ崎町上原1−120


wikipedia 騎兵26連隊 、、、、、記事ないのか、書かないと、、、、
https://ja.wikipedia.org/wiki/%E9%A8%8E%E5%85%B5%E7%AC%AC26%E9%80%A3%E9%9A%8A

wikipedia 老河口作戦 

https://ja.wikipedia.org/wiki/%E8%80%81%E6%B2%B3%E5%8F%A3%E4%BD%9C%E6%88%A6
騎兵第二十六連隊が属する騎兵第四旅団が参加した戦い。騎兵による世界最後の大規模作戦。



騎兵第二十六連隊の老河口作戦での活躍を描いた漫画は下記となります(戦車の本ですが、この本では騎兵も取り扱っています。)


画像編集関連 リンクまとめ(随時修正)

http://pro.foto.ne.jp/.foto project ドットフォトプロジェクト 画像素材サイト
写真がフリーだそうです。

http://pixmaterial.blog38.fc2.com/blog-entry-23.htmlPhotoshopで簡単に湯気を描く方法!
簡便だけど、十分実用的です。

waifu2x
画像(特にアニメ調の画像)をなんかすごい計算して拡大できます。

ZIPの中身のディレクトリ名で、ZIPのファイル名そのものを書き換えるプログラムのサンプル

.Net Framework 4.5でZIPファイルが扱えるので(4.0以前ではできません(泣き))、そのサンプルプログラム的な何か。

ソリューションにConsoleApplication1というコンソールアプリプロジェクトがいて、そこのProgramクラスのMainに直書きの体で。

参照設定に、System.IO.Compression への参照を追加が必要です。

とりあえず作ったコードなので、このままコピペして使わないでください。安易なコピペ危険!

ただ1点わからんのが、ZipArchiveEntryで取得した対象が、ファイルなのかディレクトリなのかの判定がいまいちよくわからんのです、、

わかったら、記事を更新します。



using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {

Console.WriteLine("input dir fullpath");
string infilepaths = Console.ReadLine();
var fs = (new DirectoryInfo (infilepaths)).EnumerateFiles ("*.zip").ToList(); //ToListでList化。List化しないと以下のforeachで名前返還後のファイルが再度enumrateでひっかかるため。

int i = 0;
foreach(var zipFileInfo in fs) {
i++;
try {
string filepath = zipFileInfo.FullName; //x.Trim('"');
Console.WriteLine(i.ToString() + " 対象:" + filepath);

if(File.Exists(filepath)) {
string firstDirName = null;
string firstFileName = null;

using(ZipArchive archive = ZipFile.OpenRead(filepath)) {
foreach(ZipArchiveEntry entry in archive.Entries) {
string fullname = entry.FullName;
char lastChar = fullname[fullname.Length - 1];
bool isDirFlg = lastChar == '\\' || lastChar == '/'; //名前の最後が/か\ならDirectoryrとする、、、この判定は正しいのか?
if(isDirFlg) {
Console.Write((isDirFlg ? "Dir " : "File") + ":");
Console.WriteLine(fullname);
}
if(isDirFlg && string.IsNullOrEmpty(firstDirName)) {
firstDirName = entry.FullName.Trim('/').Trim('\\');
}
if(!isDirFlg && string.IsNullOrEmpty(firstFileName)) {
firstFileName = entry.FullName.Trim('/').Trim('\\');
}

}
}
if(!string.IsNullOrEmpty(firstDirName)) {
FileRename(filepath, firstDirName);
Console.WriteLine("SUCCESS");
} else {
Console.WriteLine("WARN:ディレクトリがないので、ファイル名で処理:" + firstFileName );
int aaa = indexOfSeparetor(firstFileName);
if(aaa > 0) {
string xName = firstFileName.Substring(0, aaa);
FileRename(filepath, xName);
Console.WriteLine("SUCCESS");
} else {
Console.WriteLine("WARN:ディレクトリが存在しない、かつ、有益なファイル名が無いので、なんもしません。");
}

}

} else {
Console.WriteLine("ERROR:そんなファイル存在しません。");
}
} catch(Exception e) {
Console.WriteLine("ERROR!!! "+e.Message);
}
}
Console.WriteLine("end.");
string a = Console.ReadLine();


}

private static int indexOfSeparetor(string instr) {
int a = instr.IndexOf('\\');
if(a >= 0) {
return a;
} else {
return instr.IndexOf('/');
}
}

private static void FileRename(string baseFileFullPath, string newName) {
FileInfo fi = new FileInfo(baseFileFullPath);
string name = fi.Name;
string newFileName = fi.Name.Replace(Path.GetFileNameWithoutExtension(fi.FullName), newName);
if(name != newFileName) {
Console.WriteLine(name + " to " + newFileName);
string destFileName = fi.FullName.Replace(name, newFileName);
File.Move(baseFileFullPath, destFileName);
} else {
Console.WriteLine("INFO:変換前と後が同じなので、何もしません。");
}
}
}
}


PHOTOSHOPで雪(吹雪?)

1.描画色白 背景色黒

2.レイヤーを白で塗る。

3.レイヤーマスク追加、4以降はレイヤーマスクに適用。

4.ノイズを加える。適当に。

5.ぼかし(ガウス)、適当に。

6.2階調化。適当に雪の粒の大きさを整える

7.ぼかし(移動)





レイヤーマスクをつかわずとも、
1.描画色白 背景色黒

2.レイヤーを白で塗る。

3.ノイズを加える。適当に。

4.ぼかし(ガウス)、適当に。

5.2階調化。適当に雪の粒の大きさを整える

6.ぼかし(移動)

7.レイヤーの表示を通常からスクリーンにする

でも同じっぽい。



参考ページ
http://cg.xyamu.net/PhotoshopElements/entry203.html

PowerShellでダウンロードした拡張子jpg-largeのファイルを一気にjpgにするコード

PowerShellでダウンロードした拡張子jpg-largeのファイルを一気にjpgにするコードを以下に示す。
ついでにpng-largeもpngにする。
適当に書いたので、問題が起きても当方は責任を取りませぬ。責任を取りませぬ。
たぶんもっとすっきりして分かりやすい書き方があると思うのですが、当方勉強中につきこれが限界です、、




# スクリプト・ファイルのパラメータを宣言
# 0:変換対象フォルダ
param(
[String]$in
)

# 与えられたパス($in)から合致するファイルリスト
# 再帰的にしたい場合は、(-recurse)を使う。
Get-ChildItem $in |
# 取得したファイルを順番に処理
ForEach-Object {
if( ( $_.GetType().Name -eq "FileInfo" ) -and ( $_.FullName.ToLower().IndexOf(".jpg-large") -ge 0 ) ){
$i_path = $_.FullName
$o_path = $_.FullName.Replace(".jpg-large",".jpg")
If(-not(Test-Path -path $o_path)) {
Rename-Item $i_path -newName $o_path
}else{
Write-Output exist $o_path
}

}
if( ( $_.GetType().Name -eq "FileInfo" ) -and ( $_.FullName.ToLower().IndexOf(".png-large") -ge 0 ) ){
$i_path = $_.FullName
$o_path = $_.FullName.Replace(".png-large",".png")
If(-not(Test-Path -path $o_path)) {
Rename-Item $i_path -newName $o_path
}else{
Write-Output exist $o_path
}

}

}

PDFから画像を抽出するサンプル01

PDFから画像を抽出するサンプル01。他にも方法があるっぽい。
というか、この方法だと成功するPDFと、EXCEPTIONでて失敗するPDFがある、、、参考ページを読んで他の方法を試さないと、、、

参考ページ:http://stackoverflow.com/questions/802269/extract-images-using-itextsharp


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iTextSharp.text.pdf;
using System.IO;
using System.Drawing.Imaging;


namespace TestProject1 {
[TestClass]
public class UnitTest1 {
[TestMethod]
public void TestMethod1() {
string source = @"C:\source.pdf";
string destDir = @"C:\out_image";
ExtractImagesFromPDF(source, destDir);
}


public static void ExtractImagesFromPDF(string sourcePdf, string outputPath) {
// NOTE: This will only get the first image it finds per page.
PdfReader pdf = new PdfReader(sourcePdf);
RandomAccessFileOrArray raf = new iTextSharp.text.pdf.RandomAccessFileOrArray(sourcePdf);

try {
for(int pageNumber = 1; pageNumber <= pdf.NumberOfPages; pageNumber++) {
PdfDictionary pg = pdf.GetPageN(pageNumber);

// recursively search pages, forms and groups for images.
PdfObject obj = FindImageInPDFDictionary(pg);
if(obj != null) {

int XrefIndex = Convert.ToInt32(((PRIndirectReference)obj).Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
PdfObject pdfObj = pdf.GetPdfObject(XrefIndex);
PdfStream pdfStrem = (PdfStream)pdfObj;
byte[] bytes = PdfReader.GetStreamBytesRaw((PRStream)pdfStrem);
if((bytes != null)) {
using(System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes)) {
memStream.Position = 0;
System.Drawing.Image img = System.Drawing.Image.FromStream(memStream);
// must save the file while stream is open.
if(!Directory.Exists(outputPath))
Directory.CreateDirectory(outputPath);

string path = Path.Combine(outputPath, String.Format(@"{0}.jpg", pageNumber));
System.Drawing.Imaging.EncoderParameters parms = new System.Drawing.Imaging.EncoderParameters(1);
parms.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0);
System.Drawing.Imaging.ImageCodecInfo jpegEncoder = GetImageEncoder(ImageFormat.Jpeg);
img.Save(path, jpegEncoder, parms);
}
}
}
}
} catch {
throw;
} finally {
pdf.Close();
raf.Close();
}


}

private static PdfObject FindImageInPDFDictionary(PdfDictionary pg) {
PdfDictionary res =
(PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));


PdfDictionary xobj =
(PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
if(xobj != null) {
foreach(PdfName name in xobj.Keys) {

PdfObject obj = xobj.Get(name);
if(obj.IsIndirect()) {
PdfDictionary tg = (PdfDictionary)PdfReader.GetPdfObject(obj);

PdfName type =
(PdfName)PdfReader.GetPdfObject(tg.Get(PdfName.SUBTYPE));

//image at the root of the pdf
if(PdfName.IMAGE.Equals(type)) {
return obj;
}// image inside a form
else if(PdfName.FORM.Equals(type)) {
return FindImageInPDFDictionary(tg);
} //image inside a group
else if(PdfName.GROUP.Equals(type)) {
return FindImageInPDFDictionary(tg);
}

}
}
}

return null;

}

public static ImageCodecInfo GetImageEncoder(ImageFormat format) {
return ImageCodecInfo.GetImageEncoders().ToList().Find(delegate(ImageCodecInfo codec) {
return codec.FormatID == format.Guid;
});
}

public static ImageCodecInfo GetImageDecoder(ImageFormat format) {
return ImageCodecInfo.GetImageDecoders().ToList().Find(delegate(ImageCodecInfo codec) {
return codec.FormatID == format.Guid;
});
}
}
}